Jon
Jon

Reputation: 40032

Using jQuery Templates and wiring up events after render

I am using jQuery Templates successfully but I have a blur function that is not getting called on the new elements being added to the page. I assume its because they are not wired up to it for some reason.

Do I need to do something to fix it or should Ichange the blur function to use jQuery live?

$('.serial').blur(function () {
//Do stuff
});

Upvotes: 1

Views: 636

Answers (1)

Thomas Clayson
Thomas Clayson

Reputation: 29925

you need to use live() on elements that are added after the DOM has finished loading.

bind() or aliases such as blur() only affect elements in the DOM at the time of calling.

eg: $('.serial').live('blur', function(){ /* do stuff */ });

Upvotes: 3

Related Questions