I am working with the jQuery UI Sortable plugin and everything works as expected accept for one issue. After I am done dragging an item to reorder the list (a list of <A>
tags) the click event fires after the drop is done.
Anyone run into this issue before? If so, how did you go about fixing it?
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
)
}
});
Just add option for sortable:
helper : 'clone'
It will prevent click event for source element and don't change anyhow UX.
See doc for "helper".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With