JQuery UI Sort Stop Event After Drag & Drop

I am working with the jQuery UI Sortable plugin and everything works as expected for one problem. After I finished dragging and dropping an element to change the order of the list (list of <A> tags), the click event fires when the quote is complete.

Has anyone encountered this problem before? If so, how did you fix it?

+6
source share
2 answers

Ok ... I figured it out.

Here is my solution:

 $(thumbOpts.container).sortable({ items: '.page', revert: true, opacity: 0.5, start: function(evt, ui) { var link = ui.item.find('a'); link.data('click-event', link.attr('onclick')); link.attr('onclick', ''); }, stop: function(evt, ui) { setTimeout( function(){ var link = ui.item.find('a'); link.attr('onclick', link.data('click-event')); }, 200 ) } }); 
+7
source

Just add an option to sort:

 helper : 'clone' 

This will prevent the click event for the source element and will not change the UX as you wish.

See doc for "helper" .

+1
source

Source: https://habr.com/ru/post/909574/


All Articles