I have a very large list of elements (14000+), I want to have a search field that, when entering text into it, filters the results and hides unrelated elements.
I am currently using this:
$.expr[':'].containsIgnoreCase = function (n, i, m) { return jQuery(n).text().toUpperCase().indexOf(m[3].toUpperCase()) >= 0; }; $("#search").on("keyup", function () { var filter = $("#search").val(); $(".list-group-item").not(":containsIgnoreCase('" + filter + "')").addClass("hidden"); $(".list-group-item:containsIgnoreCase('" + filter + "')").removeClass("hidden"); });
Which works wonderfully ... on smaller lists. This list is simply too large to manage this code.
I do not know if there is any other code that can handle this client side of many elements. If not, would it be better to leave this list empty and execute an ajax request to populate the list as matches are made?
source share