Hello!

Tell me, please, how in jQuery ui sortable to make an event call when an element with a certain class is placed in the sorting area.

For example, there is a list:

html: <ul id="sortable"> <li class="sort1">1</li> <li class="sort1">2</li> <li class="sort1">3</li> </ul> JS: var ul_sortable = $('.sortable'); ul_sortable.sortable({ revert: 100, update: function() { //сработает при перемещении объектов } }); ul_sortable.disableSelection(); 

If I put another item in the list, but with a different class, for example: " <li class="sort2">4</li> ", then the event should not work. But, if I put an element with the class sort1 , then the event should work

    1 answer 1

     ul_sortable.sortable({ revert: 100, update: function(event, ui) { if (ui.item.hasClass("sort1")) { // При перемещении элемента .sort1 } else { // В остальных случаях } } });