Salve, come da titolo stò creando un filtro per una tabella contenente tantissime righe.
Ecco cosa ho prodotto:
Di fatto il codice funziona ma mi crea uno spiacevole problema. Digitando i caratteri nell'input parte lo script ma essendo molto lunga la tabella da filtrare, la digitazione di blocca. Alla fine la tabella viene filtrata correttamente ma vorrei evitare questo blocco del cursore durante la ricerca, come posso fare?codice:$(".search").keyup(function () { if( $(this).val().replace(/ /g,'').length > 2) { //split the current value of searchInput var data = this.value.split(" "); //recupero la riga in cui cercare var row = $(this).data("match"); //create a jquery object of the rows var jo = $(".rows").find("."+row+"-row"); if (this.value == "") { jo.parent("tr").show(); return; } //hide all the rows jo.parent("tr").hide(); //Recusively filter the jquery object to get results. jo.parent("tr").filter(function (i, v) { var $t = $(this); for (var d = 0; d < data.length; ++d) { if ($t.is(":contains('" + data[d] + "')")) { return true; } } return false; }) //show the rows that match. .show(); } else if( $(this).val().replace(/ /g,'').length <= 2 ){ $(".rows").find("tr").show(); } });
Grazie in anticipo !

Rispondi quotando