JQuery UI sortable: restore position based on some condition

前端 未结 3 1082
执念已碎
执念已碎 2020-12-14 11:57

I call sortable.stop() to make an ajax call to store some data after drag & drop operation.

When the ajax call returns an error (application logic e

3条回答
  •  轮回少年
    2020-12-14 12:53

    Thanks, liveat60fps , its the second statement out of the two which you only need.

    $('#some-list').sortable({
    
          // other options here,
      receive: function(event, ui) {
    
        // ajax or function here
        if(somethingWentWrong) {
           $(this).sortable('cancel');
           $(ui.sender).sortable('cancel');
        }    
      }    
    });
    

    This way on a certain condition, you can revrt back to the orignal state.

提交回复
热议问题