[英]Add ID when draggable is dropped in a droppable zone - jQuery Draggables
[英]Why can't I get Draggable ID when Dropped in a Droppable?
我在使用ui.draggable时遇到问题。 我希望能够返回其ID。 它返回的所有内容都是不确定的,我不理解。
这是我的挂断电话。
$( ".currqcontainer" ).droppable({
accept: ".currqwrapper",
drop: function (ui, event) {
alert("dropped");
var testid = $(ui.draggable).attr('id');
alert(testid);
}
});
这是我可拖动的初始化...
$( ".currqwrapper" ).draggable({ revert: "invalid" });
我正在使用此脚本创建currqwrapper实例。
var $div = $("<div/>", {id: objectID, class: "currqwrapper", text: question});
$("#currQ" + (i+1)).append($div);
如果您能告诉我为什么我无法正确读取ID,那将是很好的。 显然,我也可以提供您需要的其他任何东西!
这是我的CONSOLE.LOG(UI),它在#ZiuFEYAcpP中具有我需要的ID,但是我不确定如何调用它吗? 我注意到它在toElement中...
toElement: div#ZiuFEYAcpP.currqwrapper.ui-draggable.ui-draggable-handle
accessKey: ""
align: ""
attributes: NamedNodeMap
0: id
baseURI: null
childNodes: NodeList[1]
firstChild: text
baseURI: null
childNodes: NodeList[0]
data: "ZiuFEYAcpP"
firstChild: null
lastChild: null
length: 10
localName: null
namespaceURI: null
nextElementSibling: null
nextSibling: null
nodeName: "#text"
nodeType: 3
nodeValue: "ZiuFEYAcpP"
您已在drop事件上反转了参数。 代替
drop: function (ui, event) {...
写
drop: function (event, ui) {
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.