gpt4 book ai didi

Jquery-UI 可排序 : How to tell if sorting was canceled in stop callback?

转载 作者:行者123 更新时间:2023-12-01 00:30:58 24 4
gpt4 key购买 nike

我设置了一个带有 stop 回调的可排序对象,并绑定(bind)了 esc 来取消当前排序。在 stop 回调中,如何判断当前排序是取消还是完成?

这是我当前的代码片段:

this.$("tbody").sortable({
start: function() {
shortcut.add("esc", function() {
that.$("tbody").sortable("cancel");
});
},
handle: ".sortable-handle",
stop: function(e, ui) {
shortcut.remove("esc");
// how to check if cancel was called during sorting?
if (!e.canceled) {
// save new state
}
}
});

最佳答案

在停止函数中尝试这个。

stop: function(e, ui) {
if(ui.item.sortable._isCanceled) {
console.log('Sort action was canceled');
} else {
console.log('Sort action was not canceled');
}
}

关于Jquery-UI 可排序 : How to tell if sorting was canceled in stop callback?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30197118/

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