2016-10-29 3 views
0

削除操作が正常に完了したら、モーダルを解除するという課題に直面しています。以下はボタンをクリックしてもモーダルダイヤルボックスが存在する

アクションでモーダルのスクリーンショットです:

Confirm Delete modal

「キャンセル」ボタンの上に私をクリックすると、「削除」ボタンとは異なり、予想通り、モーダルが閉じます。成功した操作であっても。

私はおそらく間違っていますが、どうすれば修正できますか?

以下は私のコードです。

モーダルダイアログボックス:

<div class="modal fade" id="confirm-delete" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> 
    <div class="modal-dialog"> 
     <div class="modal-content"> 

      <div class="modal-header"> 
       <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button> 
       <h4 class="modal-title" id="myModalLabel">Confirm Delete</h4> 
      </div> 

      <div class="modal-body"> 
       <p>You are about to delete one track, this procedure is irreversible.</p> 
       <p>Do you want to proceed?</p> 
       <p class="debug-url"></p> 
      </div> 

      <div class="modal-footer"> 
       <button type="button" class="btn btn-default" data-dismiss="modal">Cancel</button> 
       <a class="btn btn-danger btn-ok">Delete</a> 
      </div> 
     </div> 
    </div> 
</div> 

モーダルダイアログボックスをトリガーボタンの背後にあるコードは次のとおりです。

<button type="button" class="btn btn-danger" data-toggle="modal" data-target="#confirm-delete" id="delete" style="display: none;">Delete</button> 
その後

、私のスクリプト(すべての操作を処理するために) :

$('#confirm-delete').on('show.bs.modal', function(e) { 
    var rowid = json_array['rowid']; 
    $('.btn-ok').click(function() { 
     $.ajax({ 
      url: 'delete_record.php', 
      type: "post", 
      async: true, 
      data: ({ row_id : rowid }), 
      success: function(data) { 
      } 
     }); 
    }); 
); 

答えて

0

$('#modal').modal('toggle');

id/classを変更すると動作するはずです。基本的に開いている場合は閉じるように切り替え、逆の場合は閉じます。

+0

一部が? –

+0

@RubelDinira、私の[answer](http://stackoverflow.com/a/40316736/2545680)を確認してください。 –

+0

@RabelDinira Maximusがそれを手に入れました! :P –

1

これはそれを行う必要があります:私は、このコードの一部を追加する必要があります

$('#confirm-delete').on('show.bs.modal', function(e) { 
    var rowid = json_array['rowid']; 
    var instance = $(this); 
    $('.btn-ok').click(function(){ 
     instance.modal('hide');           
     $.ajax({ 
      url: 'delete_record.php', 
      type: "post", 
      async: true, 
      data: ({ row_id : rowid }), 
      success: function(data) { 
      }            
     });           
    }); 
); 
+0

あなたの助けのために多くのおかげでくそ –

+0

助けがあれば、あなたはそれをupvoteまたは受け入れることができます) –

関連する問題