【发布时间】:2017-06-23 10:25:01
【问题描述】:
我有一堆 DIV 用于允许用户将其他 DIV 放到上面。这将是“填空”之类的事情。 droppable 是句子中的空白,而 droppable 是他们可以选择的答案。
我现在遇到的问题是,当他们将答案 div 放到可放置的 div 上时,我的函数从可拖动元素中删除了可拖动元素,但可放置元素仍然能够将更多的 div 放置到它上面。
我想知道我怎样才能让它禁用可放置的 div,这样一旦“答案”被放到它上面就是唯一可以做的事情。
这是我的函数目前的样子:
function handleCardDropOne(event, ui) {
var cardValue = ui.draggable.attr('id');
ui.draggable('disable');
$(this).droppable('disable');
ui.draggable.position({ of: $(this),
my: 'left top',
at: 'left top'});
ui.draggable.draggable('option', 'revert', false);
};
【问题讨论】:
-
你可以创建一个小提琴来复制你的问题以获得更快的解决方案
-
使用可放置小部件的 'drop' 事件。
$("#droppable").droppable({drop : function(){ $(this).droppable( "option", "disabled", true ) }});api.jqueryui.com/droppable/#option-disabledapi.jqueryui.com/droppable/#event-drop
标签: javascript jquery html jquery-ui