开发者

Prevent click events on Sortable of jQueryUI

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 draggab开发者_如何学JAVAle, 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 ?


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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜