My jQuery-foo is not up to this one. I've searched and can't find a matched problem, so I'm thinking I'm doing something pretty wrong.
Client is using IE9 (woot). Code works as I expect on FF & Chrome.
My page periodically refreshes the data within a table via ajax and then updates the html via jQuery. There is a textarea within the table that I want to know when the user is finished inputting text so that I can ajax the new data into the DB. I'm using blur and waiting for a click anywhere outside the textarea to trigger the ajax (no submit button). Works fine except IE9, where it only catches the blur if the user clicks into another textarea. So, if user finishes typing and clicks somewhere else on the page (other than another textarea), in IE9 the blur is missed.
Because of the dynamically updated html, I can't do a simple:
$('.comments').on('blur', function () {
doStuff();
})
I believe I need to delegate the blur function, as the textareas are dynamically updated periodically:
$('#table1').on('blur', '.comments', function () {
doStuff();
})
That works everywhere except IE9, where it works only if user clicks on another textarea.
I've tried using
$(document) instead of $('#table1')
and both work exactly the same (though I understand the efficiency is a little different).
Any thoughts? I suppose I could use keyUp with a timer, but that seems a bit silly when the current code works outside of IE9. Tried mouseout but that's no good with multiple textareas obviously...???
@Sampson was right - I needed to show a lot more information. (I couldn't)
I will post here, as this may help someone in future with a similar issue.
Problem was, I had a 3rd party (tablesorter) that was calling another script (parser), that added a second blur, as well as quite a few other listeners onto the same inputs. They stepped on each other and cancelled each other out enough to cause a problem.
Most browsers didn't have an issue, but IE9 did. Not IE9's fault, mine for trying to do too much sloppily.
The key hint that led me to the fault was that my blur would work when not typing into the textarea. So if I clicked in and then clicked out - perfect. But, when typing and then clicking out, nothing. Which got me thinking something was stepping on the blur... and it was.
HTH someone