How to remove jQuery UI sorted by item?

Possible duplicate:
JQuery Sortable Lists and Fixed / Locked Items

I associate sorting with such an element:

$('#elem').sortable({ items: 'li', placeholder: 'drop-highlight', forcePlaceholderSize: true, revert: true }); 

In a specific event, I want to no longer allow sorting of this element. How to cancel it?

All of them were tested individually and all failed (i.e. #elem was still sorted afterwards):

 $('#elem').unbind('sort'); $('#elem').sortable('destroy'); $('#elem').sortable('option', 'sort', null); 
+7
source share
2 answers

Yes, this is su ** s :-( it removes functionality and css classes / injects intervals after 1 second (to destroy, as you can see, just kill the widget, not the added classes or tags)

 $('#elem').sortable({ items: 'li', placeholder: 'drop-highlight', forcePlaceholderSize: true, revert: true }); 

put this code in a handler when you need an "unsortable" list

 function() { $("#elem").sortable("destroy"); //call widget-function destroy $("#elem li").removeClass('ui-state-default'); $("#elem li span").remove(); } 

$ ("# el") is sorted ("destroy"). actually destroys the sortable functionality, it just forgets to clear.

+6
source

If you want to disable sorting, try this:

 $("#elem").sortable("disable"); 

and to go back

 $("#elem").sortable("enable" ); 
0
source

All Articles