Question

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?

Était-ce utile?

La 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)

Autres conseils

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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top