HTMLSnippet Add-on and DOM Loading

2
Hi, I'm using the HTMLSnippet Add-on to execute some Javascript but because of how Mendix is loading the views and datagrids into the DOM, the Javascript is not being applied to the DOM nodes loaded after the page has finished loading. Using mx.addOnLoad(); doesn't work enough to solve the problem but I found that using something like the below code works to fire off dojo.query() every time a DOM node is inserted: mx.addOnLoad(function () { document.body.addEventListener("DOMNodeInserted", function(evt) { //execute dojo.query(); }, false); }); However, I understand that the DOMNodeInserted event is deprecated in W3C so we may not rely on it in the future. Does anyone know of a better method to apply Javascript to nodes which are loaded after the page load is finished? Thank you, Anthony
asked
2 answers
1

see ajaxian

answered
0

Hi Anthony,

 

I see it’s been seven year…. did you find a solution in the end? ^^

 

I also have a JS script that needs to run after the whole page is done loading and I now have to work with a setTimeout function which slows down the app and still doesn’t work if the network is slow.

 

Hope to hear from you!

 

Kind regards,

 

Paul

answered