Sortable: Lock an element ?

Created on 30 Aug 2016  路  5Comments  路  Source: SortableJS/Sortable

Hello everyone. I wonder if it's possible to lock an element in a list.

For example, I've got a list that I can sort :
<ul>
<li>...</li>
<li>...</li>
<li class='locked'>...</li>
</ul>

I used the filter to my .locked element but the others <li> can be positioned below my .locked element.

Is there a way to prevent this ?

Thanks !

Most helpful comment

onMove:function (evt) {
        if (evt.related)
        {
            return !evt.related.classList.contains('locked');
        }
    }

hope can help you.

All 5 comments

Create example on jsbin.com (draft)

Thanks for your reply.
As you can see on this JS Bin I can drag my first li under my .locked li.
I'd like to keep my .locked li always at the end of my ul. Is there a way to do this with the library?

onMove:function (evt) {
        if (evt.related)
        {
            return !evt.related.classList.contains('locked');
        }
    }

hope can help you.

It works fine ! Exactly what I need ! Thanks !

onMove:function (evt) {
        if (evt.related)
        {
            return !evt.related.classList.contains('locked');
        }
    }

hope can help you.

Thank you for your solution.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Webifi picture Webifi  路  3Comments

benfoster picture benfoster  路  3Comments

chrishaigy picture chrishaigy  路  3Comments

FINDarkside picture FINDarkside  路  3Comments

kaermomo picture kaermomo  路  3Comments