dongsu7049 2017-01-19 15:59
浏览 37

Codeigniter Bootstrap模态删除

So I wanted to delete a row in a table using a delete button, which will then show a modal to confirm the delete process. However, I need to pass the ID, in this case I used filename, to the URL in order to complete the delete process. However, I can't seem to pass the complete URL in order to delete in the "YES" button in the modal. I am trying to simulate a process like this: Plunker

Here's the code.

Modal:

<div class="modal-body text-center">
      <p> Are you sure you want to remove this from the list? </p><br><br>
      <button type="submit" class="btn btn-custom-1">Yes</button>
      <button type="button" class="btn btn-custom" data-dismiss="modal">Cancel</button>
</div>

Delete Button:

<button type="button" class="btn btn-custom-3" data-href="<?php echo base_url() . 'admin_forms/delete_carsticker/' . $row->filename; ?>" data-toggle="modal" data-target="#delete-modal"><span class="glyphicon glyphicon-trash" aria-hidden="true"></span>  Delete </button>

Javascript:

  $('#delete-modal').on('show.bs.modal', function(e) {
    $(this).find('.btn-custom-1').attr('href', $(e.relatedTarget).data('href'));
});
  • 写回答

2条回答 默认 最新

  • dtvnbe1428 2017-01-19 16:50
    关注

    I'd use a simple global variable to store the ID.

    var delete_id = ""; // or a file name
    
    $(document).on('click','.btn-custom-3', function(){
        delete_id = $(this).attr("data-href");
        // id also open the modal via jQuery too...  
    });
    

    then when you do the YES use the delete_id.

    $(document).on('click','.btn-custom-1', function(){
        if(delete_id != ""){
            // do something with it and come the modal but you can close it like you are doing it directly in the HTML...
        }
    });
    
    评论

报告相同问题?

悬赏问题

  • ¥15 使用EMD去噪处理RML2016数据集时候的原理
  • ¥15 神经网络预测均方误差很小 但是图像上看着差别太大
  • ¥15 Oracle中如何从clob类型截取特定字符串后面的字符
  • ¥15 想通过pywinauto自动电机应用程序按钮,但是找不到应用程序按钮信息
  • ¥15 如何在炒股软件中,爬到我想看的日k线
  • ¥15 seatunnel 怎么配置Elasticsearch
  • ¥15 PSCAD安装问题 ERROR: Visual Studio 2013, 2015, 2017 or 2019 is not found in the system.
  • ¥15 (标签-MATLAB|关键词-多址)
  • ¥15 关于#MATLAB#的问题,如何解决?(相关搜索:信噪比,系统容量)
  • ¥500 52810做蓝牙接受端