Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to turn off sorting with jQueryUI sortable?

I have implemented jQueryUI sortable list and it works really nice. At some point in time, I wish to disable further sorting and keep item order as it is, without user being able to change it.

It tried something this:

$('.sortable').sortable('disable');  

and this:

$('.sortable').each(function() { $(this).sortable('disable'); }); 

and:

$('.sortable').disable();  

and:

$('.sortable').cancel();  

and various combinations of all that. All without success.

Can anyone tell ne The Right Way™ to do it?

Update: I'm using jQuery 1.3.2 and jQueryUI 1.7.2. A possible problem could be that I have two independent sortable lists on the page, so I have sortable1 and sortable2 classes. I'm actually doing:

$('.sortable2').sortable('disable');  

Update2: the problem was me using .sortable instead of #sortable. Everything works fine now.

like image 980
Milan Babuškov Avatar asked Jul 23 '09 00:07

Milan Babuškov


People also ask

How to disable Sortable in jQuery?

$('. sortable'). each(function() { $(this). sortable('disable'); });

What is a sortable list?

sortable-list is a custom element that allows you to sort an element from a list by dragging it.

How does jquery sortable work?

jQueryUI provides sortable() method to reorder elements in list or grid using the mouse. This method performs sortability action based upon an operation string passed as the first parameter.


1 Answers

$(ui.sender).sortable( "disable" ) 
like image 180
isxaker Avatar answered Sep 30 '22 23:09

isxaker