Search code examples
jqueryjquery-ui-sortablenested-sortable

Disable drag specific item


I found a nice script, http://mjsarfatti.com/sandbox/nestedSortable/, which is almost perfect for me. I just can't find out one little thing.

I want to disable some items to drag. I looked in the readme, tried some options, but didn't get what I wanted.

Could someone tell me how I can disable an item to be dragged?


Solution

  • All the instructions are here http://jqueryui.com/sortable/#items

    In your code that I extracted and put here http://jsfiddle.net/axgTF/1/

    change

    items: "li",
    

    to

    items: "li:not(.dontsortme)",
    

    and add that class to the items you want to disable from sorting, e.g.

    <li id="list_10" class="dontsortme"><div><span class="disclose"><span></span></span>Item 5</div>
    

    Which you can see working here http://jsfiddle.net/axgTF/2/ (Item 5 is disabled)