1
我是jQuery的新手,我正在使用droppable API。jquery droppable只有一個孩子
我想擁有一組div,它們都可以擁有一個且只能放置一個可放置物品。我已經將我的Droppable div的類設置爲inv。我可以將項目放入div中,但是我可以找到一種方法在放置函數中拒絕放置一次。
我想能夠檢測到我的div已經有一個孩子,如果它恢復了dopped元素。
我的代碼目前看起來像這樣
$("div.inv").droppable(
{
drop: function(event, ui)
{
childCount = $(this).children().length;
if (childCount !=0)
{
//revert droppable to initial position
return;
}
//if there is a child revert and return
$(this)
.addClass("ui-state-highlight")
.append($(ui.draggable))
}
});
但是如何啓用它,如果我再出來,如果它被禁用拖動項目? – 2013-10-29 13:16:54