【发布时间】:2015-07-09 03:36:03
【问题描述】:
使用 bootstrap-table 插件 (http://bootstrap-table.wenzhixin.net.cn/documentation/) 我正在尝试设置一个在加载表时自动搜索默认搜索值的表。我在 javascript 文件中设置了默认值,但它不会启动搜索,除非您单击搜索框并按任意键。
我还尝试使用此页面上推荐的一些代码 (with the Bootstrap Table plugin, how to set a search string on first load?) 创建一个新的 javascript 文件以在其他所有操作之后加载,它设置了初始值,但有同样的问题。我试图弄清楚如何在不按键的情况下初始化搜索。
var srch_str = 'v1.00';
var bstable_first_load = true;
$(document.getElementById('server_table')).on('load-success.bs.table',function () {//when the table is loaded the first time and visible, set the search string...
if(srch_str.length > 0 && bstable_first_load){$('.fixed-table-toolbar').find('.search > :input').val(srch_str);
bstable_first_load = false};
})
【问题讨论】:
-
您的控制台有错误吗?另外我认为它不会影响任何东西,但是您使用的是 Javascript 的
document.getElementById()和 jQuery 的.on()函数。这对我来说看起来很奇怪:P -
不,它不会给出任何错误。
标签: javascript jquery twitter-bootstrap bootstrap-table