I have read and (for the most part) understood the article about event
delegation that's listed here:
I have successfully used the event delegation to trigger events on
click, as listed in the article. Now I want to do the same with form
inputs, but the blur event seems not to work like this:
$(document).ready(function() {
$('body').blur( function(event) {
if($(event.target).is('input[@class=aantal]')) {
var id = $(event.target).attr("id").substr($
(event.target).attr("id").lastIndexOf('_')+1);
updatePrice(id);
}
});
});
It works if I use "click" instead of "blur" but then the function
updatePrice() isn't fired when the user uses the keyboard tab to skip
through form inputs.
The form inputs are placed there by an ajax function, so they're not
in the dom when the page is loaded.
Any idea on how to get the blur event working?