我有一个基于 javascript 的 bootstrapTable,可以动态生成表格和数据。
我在尝试将一些 CSS 样式和类应用于 this question 中生成的一些 td
时遇到问题。 。我意识到我认为我的问题是表未完全加载,这导致我的代码无法工作。如果我手动编写表代码,但不能动态编写,则效果很好。
我尝试使用 load
事件来等待表加载,但这似乎不起作用
$table.load(function() {
// do something
});
我需要什么 jquery 才能在执行某些操作之前等待 $table
完全加载?
javascript 表格
var $table = $('#table-javascript').bootstrapTable({
method: 'get',
url: 'bootstrap_database.php',
height: 3849,
cache: false,
striped: true,
pagination: true,
search: true,
pageSize: 100,
pageList: [100, 200, 600, 1000],
minimumCountColumns: 2,
clickToSelect: true,
columns: [{
field: 'ID',
title: 'ID',
align: 'center',
visible: false
},{
field: 'backlink',
title: 'Backlink',
align: 'left',
width: '20'
},{
field: 'indexed',
title: 'PI',
align: 'center',
width: '20',
},{
field: 'dindexed',
title: 'DI',
align: 'center',
width: '20',
},{
field: 'moz',
title: 'MOZ',
align: 'center',
width: '20',
},{
field: 'email',
title: 'EM',
align: 'center',
width: '20'
},{
field: 'social',
title: 'SOC+',
align: 'center',
width: '20'
},{
field: 'whois',
title: 'WHO',
align: 'center',
width: '20'
},{
field: 'notes',
title: 'NT',
align: 'center',
width: '20'
},{
field: 'removed',
title: 'RM',
align: 'center',
width: '20'
},{
field: 'import_label',
title: 'SR',
align: 'center',
width: '20'
},{
field: 'important',
title: 'IM',
align: 'center',
width: '20'
},{
field: 'refresh',
title: 'RF',
align: 'center',
width: '20',
class: 'refreshstats'
},{
field: 'exempt',
title: 'EX',
align: 'center',
width: '20',
},{
field: 'spammy',
title: 'SP',
align: 'center',
width: '20',
}]
});
最佳答案
您可以覆盖许多事件:
onAll: function (name, args) {
return false;
},
onClickRow: function (item, $element) {
return false;
},
onDblClickRow: function (item, $element) {
return false;
},
onSort: function (name, order) {
return false;
},
onCheck: function (row) {
return false;
},
onUncheck: function (row) {
return false;
},
onCheckAll: function () {
return false;
},
onUncheckAll: function () {
return false;
},
onLoadSuccess: function (data) {
return false;
},
onLoadError: function (status) {
return false;
},
onColumnSwitch: function (field, checked) {
return false;
},
onPageChange: function (number, size) {
return false;
},
onSearch: function (text) {
return false;
},
onToggle: function (cardView) {
return false;
},
onPreBody: function (data) {
return false;
},
onPostBody: function () {
return false;
},
onPostHeader: function () {
return false;
},
onPreRows: function () {
return false;
},
onPostRows: function () {
return false;
}
对这个插件的工作原理一无所知,我建议尝试 onLoadSuccess
或 onPostRows
:
var $table = $('#table-javascript').bootstrapTable({
method: 'get',
...
onLoadSuccess: function() {
// do something
},
...
});
关于jquery - 等到 bootstrapTable 完全加载后再执行某些操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30336431/