如果这个问题已经在另一个问题中得到了回答,我很抱歉,但我没有找到与我的问题相关的答案!
我正在尝试测试一个jQuery可拖动元素是否被放置在不合法的放置目标之外。通常情况下,可以通过还原可拖动元素来解决90%的问题,但我不想这样做。相反,如果可拖动元素被放置在放置目标上,我想执行一件事情(运行良好!),如果它被放置在所有可能的放置目标之外,则执行其他操作(目前让我感到困扰!)。
简而言之:
jQuery('#droppable').droppable(
{
accept: '#draggable',
drop: function(event, ui)
{
// awesome code that works and handles successful drops...
}
});
jQuery('#draggable').draggable(
{
revert: false,
stop: function()
{
// need some way to check to see if this draggable has been dropped
// successfully or not on an appropriate droppable...
// I wish I could comment out my headache here like this too...
}
});
我觉得我可能忽略了一些非常明显的东西...提前感谢任何帮助!
ui.draggable.data('dropped', true);
应该改为ui.helper.data('dropped', true);
,是吗? - maryisdead