JS等待数据台服务数据加载
我有一个用于加载数据的表,并且编写了一个代码,该代码将每个表分配给HREF带有JavaScript,因为启用了Serveride,我无法为每个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;
});
});
} );
}
我调用nistion_href_to_tables
在initcomplete
eg中的功能:
"initComplete": function( settings, json ) {
assign_href_to_tables();
},
如果我在文档上调用函数,则只会影响首页。当页面更改或搜索请求时,请查询HREF停止工作。
我试图跟随此 link 但是我不明白它,也无法实施它。
只要我理解,问题出现initcomplete
就不会等待表数据加载。我不知道我的工作缺少什么。谢谢。
I have a table for loading data and i wrote a code which assigns each table an href with javascript since the serverside enabled i can't assign each td a href. Therefore, each time page changes or search query invoked i need to assign href to client side table rows.
Here is what i put so far:
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;
});
});
} );
}
I invoke the assign_href_to_tables
function in initComplete
e.g.:
"initComplete": function( settings, json ) {
assign_href_to_tables();
},
If i call the function on document ready it will affect only the first page. When page changes or search request queried href stops working.
I tried to follow this link but i did not understand it nor i could implement it.
As long as i understand, the problem arise initComplete
does not wait for the table data to load. I don't know what is missing in my work. Thank you.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论