Twitter Bootstrap模态表单和数据表

时间:2013-02-07 09:55:26

标签: jquery twitter-bootstrap datatables

我正在使用带有Twitter Bootstrap的数据表来显示表格中的数据。我使用Bootstrap中的Modal表单编写了从表中删除数据的代码。无论第一页中显示的是什么(分页中的默认视图)都会被删除,但是一旦加载了下一页,当单击删除按钮时,弹出窗体不会弹出。希望有人能给我一个解决方案

提前致谢。

删除按钮

<td><a href="" data-id="<?=$row['_id']?>" class="removeData"><i class="icon-trash"></i></a></td>

删除模态

<div id="modal_dat_remove" class="modal hide fade">
         <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
            <h3>Delete data</h3>
         </div>
         <div class="modal-body">
            <p>Are you sure that you want to perform this operation?</p>
         </div>
         <div class="modal-footer">
            <a href="#" id="deleteID" class="btn btn-danger" data-delete="" data-loading-text="Deleting...">Delete</a>
            <a href="#" class="btn" data-dismiss="modal" aria-hidden="true">Close</a>
         </div>
    </div>

Javascript函数

 $(".removeData").click(function(){ 

    // set 'delete' parameter of modal to row id
 $('#modal_dat_remove a:nth-child(1)').data('delete', $(this).data('id'));

//show the modal
$('#modal_dat_remove').modal('show');
return false;
 });

 //click delete button in the modal
$("#deleteID").click(function(e){   

//delete the row from database
   $.post('<?=base_url()?>mapping/deleteRow', { dat_id : $(this).data('delete') }, function(data) {
    // handle ajax response
});

 });

0 个答案:

没有答案