为什么我不能在丢弃Droppable时获得可拖动的ID?

时间:2014-08-01 22:10:24

标签: javascript jquery jquery-ui draggable 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)它有我需要的ID #ZiuFEYAcpP但是我不知道如何调用它?我注意到它在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"

1 个答案:

答案 0 :(得分:0)

您已撤消drop事件的参数。 而不是

drop: function (ui, event) {...

drop: function (event, ui) {