开发者

How to trigger drop in jQuery?

开发者 https://www.devze.com 2022-12-26 10:22 出处:网络
$(item).droppable({ drop: function(event, ui) { console.log(\"triggered\"); } }); I try to call drop by $(item).trigger(\"drop\", [{},{draggable : $(target_item)}]);
$(item).droppable({
    drop: function(event, ui) {
        console.log("triggered");
    }
});

I try to call drop by

$(item).trigger("drop", [{},{draggable : $(target_item)}]);

But it doesn't work, any i开发者_开发技巧deas?


Maybe what you want to do is:

$(item).bind('dropthis', function(e){
        console.log('triggered');
}).droppable({
    drop: function(event, ui) {
        $(this).trigger('dropthis',[event, ui]);
        }
});

And call the drop event by:

$(item).trigger("dropthis", [{},{draggable : $(target_item)}]);


try out jQuery.simulate plugin

Something like this should work.

var dropZone = $("#dropZone").offset() //get dropZone's offset object
$("#dragableEle").simulate("drag", {
     dx: dropZone.left, // move to this x
     dy: dropZone.top, // move to this y
     speed:5000 // set speed
});
0

精彩评论

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