我在尝试将元素拖到占位符中时遇到问题,占位符中包含另一个占位符。
我想说:
page.find("ol.question-group-placeholder").droppable({
accept: ".question-type, .question-text",
activeClass: "placeholder-active",
hoverClass: "placeholder-hover",
drop: function (event, ui) {
alert("Dropped to the question group!");
}
});
和
page.find("ol.question-placeholder").droppable({
accept: ".question-text",
activeClass: "placeholder-active",
hoverClass: "placeholder-hover",
drop: function (event, ui) {
alert("Dropped to the question!")
}
});
第一个是问题组OL,它只接受带有类的LI:.question-type
和.question-text
。
第二个是问题OL,它只接受LI的类:question-text
。
当我在问题组占位符中拖动具有类question-type
的元素时,这将成为问题文本的占位符,但问题组占位符也会接受问题出现的问题文本元素。
问题是当有两个占位符时:question-group-placeholder
和question-placeholder
当我拖动文本元素时,两个事件都被调用,我看到两个警告是有意义的,因为它们都接受{{1元素。我想要实现的是,如果我将问题文本拖到特定的占位符,它将只会在这个占位符上结束,而不是在所有这些占位符上。有什么方法可以做到吗?
答案 0 :(得分:0)
找到解决方案。
我需要在两个选项上将贪婪选项设置为true(greedy: true
)。