提问人:tealy 提问时间:6/11/2022 更新时间:6/11/2022 访问量:112
JS 等待 Datatables 服务器端数据加载
JS wait for Datatables serverside data to load
问:
我有一个用于加载数据的表,我写了一个代码,为每个表分配一个带有 javascript 的 href,因为服务器端启用了我无法为每个 td 分配一个 href。因此,每次页面更改或调用搜索查询时,我都需要将 href 分配给客户端表行。
这是我到目前为止所说的:
function assign_href_to_tables() {
console.log("Run assign_href_to_tables");
// access all td variables when serverside enabled.
$('#table').on( 'order.dt', function () {
var table_rows = $('#table').find('tbody tr');
console.log(table_rows)
// scan through table rows and assign onclick event to each row.
table_rows.each(function(index, element) {
$(this).click(function() {
var id = $(this).find('td:nth-child(1)').text();
// reidrect to the edit page with the id of the clicked row
window.document.location = '/detail/' + id;
});
});
} );
}
我在例如:assign_href_to_tables
initComplete
"initComplete": function( settings, json ) {
assign_href_to_tables();
},
如果我在文档就绪时调用该函数,它只会影响第一页。当页面更改或搜索请求查询时,href 停止工作。
我试图点击这个链接,但我不明白它,也无法实现它。
只要我理解,问题出现不会等待表数据加载。我不知道我的工作中缺少什么。谢谢。initComplete
答: 暂无答案
评论
serverSide: true
href
initComplete