gpt4 book ai didi

恢复时的 jQuery ui.draggable 事件/状态

转载 作者:行者123 更新时间:2023-11-30 23:47:06 27 4
gpt4 key购买 nike

如果可拖动的元素被恢复,是否有办法获取信息?

我被困在这个问题上了。我想让一个元素再次可放置,但前提是位于该处的可拖动元素被移动到其他地方(意味着不会恢复)。

最佳答案

我发现可以获取有关对象是否已恢复的信息。它内置于 jQuery 中,但显然没有很好的文档记录。

本质上,这是通过使用可拖动对象的恢复选项的回调函数来完成的。

类似于以下内容:

$(".myselector").draggable(
{
revert: function(droppableObj)
{
//if false then no socket object drop occurred.
if(droppableObj === false)
{
//revert the .myselector object by returning true
return true;
}
else
{
//droppableObj was returned,
//we can perform additional checks here if we like
//alert(droppableObj.attr('id')); would work fine

//return false so that the .myselector object does not revert
return false;
}
}
});

参见http://www.agilepro.com/blog/2009/12/while-this-functionality-is-built-into.html了解更多详情。

关于恢复时的 jQuery ui.draggable 事件/状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1853230/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com