Jquery Create Event [www.erichynds.com]

The jQuery live event handler can monitor the DOM for changes and add event handlers to those elements that match a selector. It can not bind a function that fires when the DOM changes to check if a specific element has been added. Often when you need to work with third-party code, you might need to wait for an element to be added as the result of an Ajax request.

In this case you can use the create-event plugin. You can bind the create event to the eventual parent element where a new element will be created and trigger whatever code you need that relies on the new element's existence.

You can use this to add a plugin or just run some code:

// when a new div.foo element enters the DOM, call somePlugin() on it.
$("div.foo").live("create", function(){

// when a new div.foo element enters the DOM, trigger some code.
$("div.foo").live("create", function(){
posted in ,
Add comment