我怎样才能把元素放回原来的位置?

sortable How can I put back element to the previous position?

本文关键字:原来 位置 元素      更新时间:2023-09-26

我知道如何获得顺序,但我不知道如何在必要时将元素放回到操作之前的位置。

请指教,非常感谢。

el.sortable({
    start: function(){   var order = etc //Got current order here//  },
    update: function(){
         //Process and etc//
         if(cancel) {
            //how can I put the element back to the position before??
         }
    },

});

$(";选择器")。sortable("cancel")会起作用(当然,在你初始化你的sortable之后,而不是在初始化之后)

el.sortable({
    start: function(){   var order = etc //Got current order here//  },
    update: function(){
         //Process and etc//
         if(cancel) { //NO NOT HERE
            //how can I put the element back to the position before??
         }
    },

});
el.sortable("cancel"); //here

看到http://api.jqueryui.com/sortable/method-cancel

取消()

取消当前可排序列表中的更改并将其恢复到该状态在当前排序开始之前。有用的停止和接收回调函数。此方法不接受任何参数。