我知道如何获取顺序,但我不知道如何在必要时将元素放回到操作之前的先前位置。
请多多指教,非常感谢。
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??
}
},
});
最佳答案
$( ".selector").sortable( "cancel") 将起作用(在初始化可排序之后,当然,不在初始化内部)
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
cancel()
Cancels a change in the current sortable and reverts it to the state prior to when the current sort was started. Useful in the stop and receive callback functions. This method does not accept any arguments.
关于javascript - 如何将元素放回到前一个位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14227448/