这里有一个类似的解决方案,唯一的区别是我想在单击按钮时以引导模式填充行的数据。每一行都有一个按钮。但是没有使用上面链接的示例中使用的那些.responsive
脚本。
这是我的表的最基本的例子。
<table id="table1">
<thead> <th>Table Data</th><th>Button</th>
<td> $data </td>
<tr><td><button id=<?php echo $row['id'] ?> data-toggle="modal" class="pay" data-target="#myModal">Pay Fees</button></td></tr>
<div class="modal fade" role="dialog" id="myModal">
<div class="modal-content">
</div>
</div>
与Jquery的以下工作:
$(".pay").on( 'click', 'tr', function (){
console.log( table.row( this ).data() );
//pay_fees($id);
});
Jquery解决方案将是首选方案。
现在我已经使用以下代码来实现这一点:
$('#table1 tbody').on( 'click', 'tr button', function () {
$('#myModal').modal('show');
$(".modal-title").html(table.row($(this).parents(':eq(1)')).data()[0]);
} );