I have a list which is sortable. Before I start sorting, I want to check if all the elements of that list are valid. If not, cancel the event and leave the list intact.
You can use the cancel method
$("#list").sortable({ connectWith: ".connectedSortable", items: '.sortable-item', handle: '.handle', placeholder: "ui-state-highlight", stop: function (event, ui) { console.log('stop') if (!valid()) { $( this ).sortable( "cancel" ); } } });
Demo: Fiddle