Is there a way have an event handler run when a dom element is removed? I have not seen this documented anywhere. It seems it mightt be possible since jQuery is able to remove data and events on element removal.
A:
Binding DOMNodeRemoved
will allow for you to detect removal of nodes inside the bound element. Works in Firefox, Iron and Opera... but not IE.
jQuery
$("#detectchanges").bind("DOMNodeRemoved",function(){
alert('Something inside of detectchanges was terminated.');
});
$("#clickme").click(function(){
$("#deleteme").remove();
});
HTML
<div id="detectchanges">
<div id="deleteme">Delete me</div>
</div>
<div id="clickme">Delete</div>
Here's an example.
Gert G
2010-08-08 03:47:31