工作,我有一個的dataTable有200多條記錄,其中每行有按鈕,刪除該記錄,當按鈕從按下一個模式引導彈出。與數據表和自舉模式
問題是,當我用dataTable中的分頁選項更改「頁面」時,模式中的信息沒有被相應的ID更新。當我點擊第一頁中的任何一行時,它都可以正常工作,但是當我更改頁面時,信息會從第一頁按下的最後一個ID中刪除。
任何想法?
彌代碼如下所示:
<table class="table table-bordered table-hover tablewithtooltip" id="dataTable">
<thead>
...
</thead>
<tbody>
<tr>
<td>
<a href="#myModal" role="button" class="btn delete-smt-btn" data-toggle="modal" id="111">Delete Row</a>
</td>
<td>Some info</td>
</tr>
<tr>
<td>
<a href="#myModal" role="button" class="btn delete-smt-btn" data-toggle="modal" id="112">Delete Row</a>
</td>
<td>Some info</td>
</tr>
...
</tbody>
</table>
這是我的jQuery:
$('body').on('hidden', '#myModal', function() {
$(this).removeData('modal');
});
var table = $('#dataTable').dataTable({
"sDom": "<'row'<'span6'l><'span6'f>r>t<'row'<'span6'i><'span6'p>>",
"sPaginationType": "bootstrap",
"aaSorting": [[ 3, "asc" ]],
"oLanguage": {
"sLengthMenu": "Mostrar _MENU_ registros por página"
}
});
$('.delete-smt-btn').on('click', function(e){
id = e.currentTarget.id;
url = "mypage.com/something?p_something=" + id;
$('#myModal').modal({
remote : url
});
$('#myModal').removeData();
});
// I have some tooltips on my table, and I was having kind of the same issue when
// I changed pages with dataTable, the tooltip wasnt showing and I solved it with
// this but I cant make it work with modal.
table.$('[rel="tooltip"], [data-toggle=tooltip]').tooltip({
html: true
}).click(function(e) {e.preventDefault();});
該解決方案完美的作品,謝謝! – filistea