Twitter bootstrap 使用搜索筛选器时是否刷新引导表jQuery?

Twitter bootstrap 使用搜索筛选器时是否刷新引导表jQuery?,twitter-bootstrap,refresh,Twitter Bootstrap,Refresh,我正在使用带有分页、搜索和可单击行的实现。当未使用搜索筛选器时,该表将按预期工作,即单击该行时,它将转到正确的链接。然而,当使用搜索过滤器时,表的逻辑认为第一行仍然是第一项,这是不正确的,因为它基于用户输入 有没有办法在输入字段中的按键事件上刷新jQuery,请记住搜索的输入字段在bootstrap-table.js文件中 html/django代码 <link href={% static "css/bootstrap-table.css" %} rel="stylesheet">

我正在使用带有分页、搜索和可单击行的实现。当未使用搜索筛选器时,该表将按预期工作,即单击该行时,它将转到正确的链接。然而,当使用搜索过滤器时,表的逻辑认为第一行仍然是第一项,这是不正确的,因为它基于用户输入

有没有办法在输入字段中的按键事件上刷新jQuery,请记住搜索的输入字段在bootstrap-table.js文件中

html/django代码

<link href={% static "css/bootstrap-table.css" %} rel="stylesheet">
<script type="text/javascript" src={% static "js/bootstrap-table.js"%}></script>

<h1>Book Exchange Library</h1>

<table class="table table-condensed" id="table" data-url={% static "json/data.json" %} data-height="619" data-pagination="true" data-search="true">
    <thead>
        <tr>
            <th data-field="title">Title</th>
            <th data-field="author">Author</th>
            <th data-field="price">Price</th>
            <th id="id_col" data-field="pk">ID</th>
        </tr>
    </thead>
</table>

<!-- need this script to refresh on keypress -->
<script>
$(function() {
$("#table").bootstrapTable({
    onClickRow: function(row) {
      window.location.href = "/books/get/" + row.pk;
    }
});
});
</script> 

图书交换图书馆
标题
作者
价格
身份证件
$(函数(){
$(“#表”).bootstrapTable({
onClickRow:函数(行){
window.location.href=“/books/get/”+row.pk;
}
});
});
bootstrap-table.js代码段(可能有帮助)

if(this.options.search){
html=[];
html.push(
'',
sprintf(“”,
this.options.formatSearch()),
'');
这个.$toolbar.append(html.join(“”));
$search=this.$toolbar.find('.search-input');
$search.off('keyup')。on('keyup',$.proxy(this.onSearch,this));
}
};
看看函数。有了它,你可以做这样的事情:

$("#table").keypress(function() {
    $("#table").bootstrapTable({
        onClickRow: function(row) {
            window.location.href = "/books/get/" + row.pk;
        }
    });
}
这可能不是解决你问题的完美方法;您可能必须更改调用.keypress的元素。但是这样的东西会运行你在函数体中输入的任何代码,只要有一个按键事件,这就是你要寻找的

$("#table").keypress(function() {
    $("#table").bootstrapTable({
        onClickRow: function(row) {
            window.location.href = "/books/get/" + row.pk;
        }
    });
}