Often a simple and effective way to achieve this is to keep track of when and where you are modifying the DOM.
You can do this by creating one central function that is always responsible for modifying the DOM. You then do whatever cleanup you need on the modified element from within this function.
In a recent application, I didn't need immediate action so I used a callback for the handly load() function, to add a class to any modified elements and then updated all modified elements every few seconds with a setInterval timer.
$($location).load("my URL", "", $location.addClass("dommodified"));
Then you can handle it however you want - e.g.
setInterval("handlemodifiedstuff();", 3000);
function handlemodifiedstuff()
{
$(".dommodified").each(function(){/* Do stuff with $(this) */});
}
0
Created by Antony Carthy on 2020-03-10 13:57:56 +0000 UTC
Share