Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

What's the best approach for initializing a Component after it's template is added to the DOM?

$
0
0
Hey folks,

I'm trying to make JS calls to modify the DOM generated by a Component and its mustache template, to initialize some layout state. If I try to do this in a Component's scope's init() function, it does not appear that the template elements have been added to the DOM yet, so selectors are failing, and the code fails to update anything.

What is the best practice for executing one-time initialization code to update the DOM using JS, after a Component has finished loading and the DOM is populated with data from the associated template?

Thanks!


Viewing all articles
Browse latest Browse all 3491

Trending Articles