But can you detect when DOM elements are created? (Which is different than adding a click event to new DOM element.)
I was looking into this issue myself recently and ultimately (through advice on Stackoverflow) decided to just ignore jQuery and to use DOM mutation events. I'm still curious if there is a way to do this using jQuery, though.
While working on this I briefly considered livequery due to this StackOverflow post (http://stackoverflow.com/questions/4818020/livequery-perform...), but soon realized that this only intercepts DOM changes made via jQuery, and won't work with code in the wild (which is what I need since it is for a Chrome extension.)
Is that a problem? You can use jQuery to wrap the event target like my example did. Or just do $(document).bind('DOMNOdeInserted', function () {}); Is that using jQuery enough? I suppose if you knew you were only using jQuery and wanted to modify the source, you could somehow hook into every function that modifies the DOM and go from there (which is what you just described with livequery).
Not really sure why your requirement is it needs to "use" jQuery though.
Not really; my code is working fine as is. I think the "problems" were 1) I was curious if there was a way to do it via jQuery instead of DOM mutation methods (looks like no) and 2) the documentation for these jQuery methods doesn't specifically mention that this case isn't covered and that the developer should look at DOM events, although that is just perhaps assumed to be default behavior when working with jQuery.
I'm writing to the people who maintain the jQuery documentation now...
I was looking into this issue myself recently and ultimately (through advice on Stackoverflow) decided to just ignore jQuery and to use DOM mutation events. I'm still curious if there is a way to do this using jQuery, though.
While working on this I briefly considered livequery due to this StackOverflow post (http://stackoverflow.com/questions/4818020/livequery-perform...), but soon realized that this only intercepts DOM changes made via jQuery, and won't work with code in the wild (which is what I need since it is for a Chrome extension.)