search - Need help with implementation of the jQuery LiveUpdate routine -


has worked liveupdate function (may bit of misnomer) found on this page? it's not live search/update function, quick filtering mechanism pre-existing list, based on pattern enter in text field.

for easier reference, i'm pasting entire function in here:

jquery.fn.liveupdate = function(list){   list = jquery(list);    if ( list.length ) {     var rows = list.children('li'),       cache = rows.map(function(){         return this.innerhtml.tolowercase();       });            .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();       });     }   } }; 

i have list, members id. , text field say, qs id.

i tried binding function in following manner:

$( '#qs' ).liveupdate( '#members' ); 

but when this, function called only once when page loaded (i put in console.logs in function) never after when text keyed text field. tried calling routine keyup() function of qs.

$( '#qs' ).keyup( function() {     $( ).liveupdate( '#members' ); }); 

this ends going infinite loops (almost) , halting "too recursion" errors.

so can please shed light on how supposed implement function?

also while @ it, can kindly explain line me:

var score = this.score(term); 

what want know member method score() coming from? didn't find such method built js or jquery.

thanks help, m^e

score() comes quicksilver library. isn't extremely clear in post, john answers same question in comments.


Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -