So, i hijacked some JS to make it so that when you were typing in a field and stopped for 1 second it would then send out an ajax request to do a search against the DB and it seemed to work beautifully. However, it seems now that its only triggering the onkepress event about every third keystroke.
for example, if i type a word then backspace once it doesn't fire off and do the magic but if i hit backspace two more times it does. Also, if i highlight the whole word/phrase i typed in and hit delete or backspace same thing. Very odd.
Here is the JS i have doing the business so if anyone sees something I don't or has some clue as to why this may be happening that would be awesome
function addTextAreaCallback(textArea, callback, delay) {
var timer = null;
textArea.onkeyup = function() {
if (timer) {
window.clearTimeout(timer);
if(!waiting){
$("#results").html("<img src='img/ajax-loader.gif' />");
waiting = 1;
}
}
timer = window.setTimeout( function() {
timer = null;
callback();
waiting = 0;
}, delay );
};
textArea = null;
}