1

I have sortable, draggable and click events binded to the same DOM element.

On sorting, I want the click event to be disabled.

I am using the following code for draggable, which works fine:

$('.selector').draggable({
    start: function(event, ui) {
    ui.helper.bind('click.prevent', function(event) {
        event.preventDefault(); 
    }); 
    },
    stop: function(event, ui) {
       setTimeout(function(){
           ui.helper.unbind('click.prevent');
       },1000);
    }
});

I got the above example while going through SF a while back.

However, the same code doesnt work when I use it for sortable.

I found out the reason being that the ui.helper is null for sortable's stop function.

Any way that i can prevent click event on sorting ?

Hrishikesh Choudhari
  • 11,617
  • 18
  • 61
  • 74
  • Possible duplicate of [jQuery UI Sortable -- How can I cancel the click event on an item that's dragged/sorted?](http://stackoverflow.com/questions/947195/jquery-ui-sortable-how-can-i-cancel-the-click-event-on-an-item-thats-dragged) – Dan Dec 14 '16 at 23:58

1 Answers1

0

jQuery UI Sortable -- How can I cancel the click event on an item that's dragged/sorted?

Community
  • 1
  • 1
machineghost
  • 33,529
  • 30
  • 159
  • 234