【问题标题】:Jquery-UI Sortable: How to tell if sorting was canceled in stop callback?Jquery-UI Sortable:如何判断停止回调中是否取消了排序?
【发布时间】:2015-07-23 16:41:50
【问题描述】:

我使用stop 回调设置了可排序并绑定esc 以取消当前排序。在stop回调中,如何判断当前排序是取消还是完成?

这是我目前的 sn-p:

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 
        }
    }
});

【问题讨论】:

    标签: jquery jquery-ui jquery-ui-sortable


    【解决方案1】:

    在停止函数里面试试这个。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-03-16
      • 1970-01-01
      • 2010-10-31
      • 1970-01-01
      • 2011-11-22
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多