2
Je suis à la recherche d'une recherche rapide en direct.jquery recherche de personne?
Quelqu'un utilise ceci? http://rikrikrik.com/jquery/quicksearch/#usage Aussi comment le combinez-vous avec la pagination ou ajax pour de grandes quantités de données?
code:
HTML:
<form method="get" autocomplete="off" action="">
<input type="text" value="" name="q" id="q"><br><br>
</form>
<ul id="posts">
<li>One</li>
<li>Two</li>
<li>Three</li>
</ul>
JS:
$('#q').liveUpdate('#posts');
utilisant comme plug-in:
jQuery.fn.liveUpdate = function(list){
list = jQuery(list);
if (list.length) {
var rows = list.children('li'),
cache = rows.map(function(){
return this.innerHTML.toLowerCase();
});
this
.keyup(filter).keyup()
.parents('form').submit(function(){
return false;
});
}
return this;
function filter(){
var term = jQuery.trim(jQuery(this).val().toLowerCase()), scores = [];
if (!term) {
rows.show();
} else {
rows.hide();
cache.each(function(i){
var score = this.score(term);
if (score > 0) { scores.push([score, i]); }
});
jQuery.each(scores.sort(function(a, b){return b[0] - a[0];}), function(){
jQuery(rows[ this[1] ]).show();
});
}
}
};
Je les ai essayé, n'a pas pu y travailler .. – matthewb
Ok, il sera nécessaire d'inclure quelques exemples pour qui peuvent vous aider –
@andres Voir ci-dessus Modifier – matthewb