I have an understanding of what the .on function does as far "defining" functions/callbacks once an element is added to the DOM.
My question is, I want to automatically FIRE an event when the element is added to the DOM.
Here's the scenario: First off, I am using AJAX to load my pages, so DOM isReady() does not help me.
User clicks link and a function is fired off with a parameter that does:
- create a series of images on a page; defines the onClick event for each image
- I then look for one of those elements and performs click() event
Problem is, the second function fires too quickly. What I want to do is WAIT for the first function to complete entirely - i.e. wait for all the elements to be created, and THEN fire the click()
I see that the now retired(?) plugin LIVEQUERY used to do that.
Live Query also has the ability to fire a function (callback) when it matches a new element and another function (callback) for when an element is no longer matched.
Is there a way to do this this with the new version(s) of jQuery?
Again, I simply want to wait until an element is added to the DOM and then trigger an event on that element.
Any guidance is greatly appreciated.