[英]Highlight search text bootstrap table
我正在尝试实现jquery 插件以突出显示我的应用程序的搜索文本,并且我正在使用这个主题,我已将 jquery 插件放入我的应用程序并添加以下行:
$table.highlight($(".search.bs.table").val());
但是搜索文本仍然没有突出显示。 有人可以解释一下,我的错误在哪里?
代码:
function initTable() {
$table.bootstrapTable({
filterControl: true,
//data: url,
//url: 'data/events.json',
height: getHeight(),
formatNoMatches: function () {
return "Please, choose your category";
}
});
// sometimes footer render error.
setTimeout(function () {
$table.bootstrapTable('resetView');
}, 200);
$table.on('check.bs.table uncheck.bs.table ' +
'check-all.bs.table uncheck-all.bs.table', function () {
$remove.prop('disabled', !$table.bootstrapTable('getSelections').length);
// save your data, here just save the current page
selections = getIdSelections();
// push or splice the selections if you want to save all data selections
});
$table.on('all.bs.table', function (e, name, args) {
console.log(name, args);
});
$table.highlight($(".search.bs.table").val());
$table.on('search.bs.table', function (e, text){
"use strict";
console.log(e);
console.log(text);
});
$remove.click(function () {
var ids = getIdSelections();
$table.bootstrapTable('remove', {
field: 'id',
values: ids
});
$remove.prop('disabled', true);
});
$(window).resize(function () {
$table.bootstrapTable('resetView', {
//height: getHeight()
});
});
}
我弄清楚,它是如何工作的在正确的代码下方(将此代码放在 inittable 中):
$table.highlight($(".search.bs.table").val());
$table.on('search.bs.table', function (e, text){
$table.highlight(text);
console.log(e);
console.log(text);
});
css:
.highlight {background-color: yellow}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.