this test : if( tbxValue != lastTbxValue ) will always return false because the function each() monoplize the unique thread. The event "onkeyup" from the textbox couldn't occur while each() is running, so tbxValue remains the same in the meantime.
Dan G. Switzer, II wrote: > > >>Thank you. >> >>Is it possible to interrupt the script each time the user enter a new >>letter >>in the search box ? > > What I'd recommend doing is building in a setTimeout() delay that would > only > fire off the event if the user pauses typing--that way you're not trying > to > fire it off for every keystroke. > > As for stop the each(), if you do a return true/false inside the callback > function, it should stop execution of the loop. > > This means you can add a condition to the loop based on a global variable > to > determine if you should stop the loop. So, something like the following > would work: > > $(".Name").each( > function (){ > // provided lastTbxValue is a global value that's updated > each > // time the value changes, this should stop the loop > if( tbxValue != lastTbxValue ) return false; > > // create a pointer to the current table cell > var oCell = $(this); > > // hide the parent > oCell.parent().[oCell.text().indexOf(tbxValue) > -1 ? "show" > : "hide"](); > } > ); > > -Dan > > > -- View this message in context: http://www.nabble.com/jquery-is%27nt-very-effective-at-execution-tf3887482s15494.html#a11054602 Sent from the JQuery mailing list archive at Nabble.com.