2015-05-12 59 views
3

我設置了stop回調排序和綁定esc取消當前排序。在stop回調中,如何判斷當前的排序是否已取消或完成?Jquery-UI Sortable:如何判斷在停止回調中排序是否被取消?

這是我目前的片段:

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

回答

0

裏面的停止功能試試這個。

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