jquery draggable停止事件 [英] jquery draggable stop event
问题描述
我已经搜索了很多。但是我找不到答案。也许是dublicate.Here是我的一些代码:
$(。box)。draggable({
revert:invalid,
stop:function(ev,ui){
// if(dropped)alert(ui) .item.attr(id);
// else alert(不丢弃);
}
});
$(。box)。droppable ({
accept:function(drag){
return $(drag).attr(data-id)=== $(this).attr(data-id);
},
drop:function(ev,ui){
}
});
我看过可放置的选项和可拖动的选项。但它没有帮助。换句话说,如何访问使用可拖动选项,事件和方法删除元素。
同时使用 jQuery Droppable,删除元素
如何获取被删除的元素ID如果从Draggable停止功能中删除它。
很容易在中获取一个
。但是不能用 draggable
在 draggable
...
我在以前的项目中试过它,就像魅力一样。
试试这个:
$(#dragable)。draggable(
{handle:p,
stop:function(event,ui){
console.log(event);
console.log($(ui.helper [0])。children()。attr('id'));
}
});
http://jsfiddle.net/rahulrulez/gg4z10v4/
I have searched a lot of.But I can't find answer.Maybe dublicate.Here is a bit of my code:
$(".box").draggable({
revert:"invalid",
stop:function(ev,ui){
//if(dropped) alert(ui.item.attr("id");
//else alert("Not dropped");
}
});
$(".box").droppable({
accept:function(drag){
return $(drag).attr("data-id")===$(this).attr("data-id");
},
drop:function(ev,ui){
}
});
I have looked droppable options and draggable options.But it isn't helpfull.In other word how to access dropped element using draggable options,events and methods. Also dublicate with jQuery Droppable, get the element dropped
How to get the dropped element Id if it is dropped from Draggable stop function.
It's easy to get one in droppable
. But not with draggable
there's hacky way to get id of dropped element on stop event in draggable
...
I tried it in my previous projects, works like charm.
Try this :
$( "#draggable" ).draggable(
{ handle: "p",
stop: function(event, ui){
console.log(event);
console.log($(ui.helper[0]).children().attr('id'));
}
});
http://jsfiddle.net/rahulrulez/gg4z10v4/
这篇关于jquery draggable停止事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!