0

我正在使用 QuickSearchJS,它按预期工作,直到进行 ajax 调用,然后它不起作用。我尝试了两种方法。有没有办法将它与 document.on 功能或任何替代方式一起使用?

第一种方式

$(function () {
    var qs = $('input#filterText').quicksearch('#a option')
});

第二种方式:

$(document).ready(function() {
    $(function () {
        var qs = $('input#filterText').quicksearch('#a option')
    });
});
4

1 回答 1

1

根据您应该qs.cache();在 ajax 调用后使用的文档。

var qs = $('input#id_search_list').quicksearch('ul#list_example li');
$('ul#list_example').append('<li>Loaded with Ajax</li>');
qs.cache();

 var qs=$('input#search').quicksearch('table tbody td');

 $("#append").on("click", function(e) {
     $("tr").append('<td>'+$("#search").val()+'</td>');
     qs.cache();
 });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.quicksearch/2.2.0/jquery.quicksearch.min.js"></script>
/* Example form */
<form>
    <input type="text" id="search">
    <input type="button" id="append" value="ajax">
</form>

/* Example table */
<table>
    <tbody>
        <tr>
            <td>Test cell</td>
            <td>Another test cell</td>
        </tr>
    </tbody>
</table>

于 2016-03-22T15:14:56.563 回答