Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 519
Write Down Avatar asked Dec 20 '25 09:12

Write Down


2 Answers

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)

like image 168
Popnoodles Avatar answered Dec 22 '25 23:12

Popnoodles


Add a class like static to the <li> elements which should not be moved then in the nestedSortable configuration specify items: 'li:not(.static)'.

Demo: Fiddle.

Here the Item 5 Cannot be moved.

like image 36
Arun P Johny Avatar answered Dec 23 '25 01:12

Arun P Johny