Is there currently a way to subscribe to an event of a wrapped set, that will trigger when any element is appended to it as a child element?
-
Dublicate http://stackoverflow.com/questions/3219758/detect-changes-in-the-dom ? – Andreas Louv Mar 23 '12 at 11:02
-
@AndreasAL: Close, except that question doesn't mention jQuery, which could change things. – T.J. Crowder Mar 23 '12 at 11:05
1 Answers
There's nothing standard (DOM or jQuery) that's broadly supported. There were mutatation events specified in the DOM2 Events spec, but they were onerous to implement, never widely implemented, and deprecated in the DOM3 Events spec.
You might be able to hack the internal domManip
function within jQuery, which is used for most of these sorts of operations; but of course that means every release of jQuery, you have to re-hack and the internals could change such that your hack doesn't work anymore (and would only work if the caller used jQuery do to the append; even in code written for jQuery I've been known to go direct to the DOM when it was convenient). There's a script in the answer accepted on the question AndreasAL found, but with the mutation events having been deprecated, well, your mileage may vary as browsers continue to update...

- 1
- 1

- 1,031,962
- 187
- 1,923
- 1,875