1

確認ボックスへの応答が否定的である場合、削除機能でソート可能をキャンセルしようとしています。これが私のソート可能な順序なしリストです。

$("#items").sortable({
    remove: function(event, ui) {  
      var id = ui.item.attr("id");
      var loadUrl = "LoadItem.action";
      var removeUrl = "RemoveItem.action";

      $.getJSON(loadUrl, {"id":id}, function(data){
        if (data.passed !== undefined){
          var answer = confirm("A status exists on this item.  Remove anyways?");
          if (!answer){
            $(this).sortable('cancel');  //<-- This is where I need help
            return false;
          }
          $.post(removeUrl, {"id":id}, function(){ 
            //alert('removed'); 
          });
        }
      });
    }
  });

キャンセルをクリックすると、$.post(removeUrl);期待どおりに起動できなくなりますが、広告申込情報は別の並べ替え可能なリストに移動されます。ラインアイテムの移動をキャンセルしたい。receive イベントで使用$(ui.sender).sortable('cancel');するとこのように動作しますが、remove イベントで同じことを行う方法はありますか?

4

1 に答える 1

1
$("#items").sortable({
  remove: function(event, ui) {  
  var id = ui.item.attr("id");
  var loadUrl = "LoadItem.action";
  var removeUrl = "RemoveItem.action";

  var self = this;
  $.getJSON(loadUrl, {"id":id}, function(data){
    if (data.passed !== undefined){
      var answer = confirm("A status exists on this item.  Remove anyways?");
      if (!answer){
        $(self).sortable('cancel');
        return false;
      }
      $.post(removeUrl, {"id":id}, function(){ 
        //alert('removed'); 
      });
    }
  });
}
});
于 2012-04-04T21:18:19.300 に答える