Finding a way to initialize a jquery component, on ALL nested templates, is surprisingly tricky. Outside Meteor this would otherwise be a simple $( document ).ready().
The component in {{> ideal}} will not initialize if you navigate to it with Iron Router, for example. It only initializes on hard page refresh (because template layout is rendered).
So instead you would have to initialize on each template that element will be used
All of these seem to happen before the route’s template content is present. I noticed that onBeforeAction required a call to next() to go on, I even tried looking for the DOM content after the next call.
I also tried rewriting our routes like this:
Router.route('someRoute', function() {
this.render('someRoute');
// look for DOM content, still not found
});
It’s very hacky, butt ugly, and not sure if it works for you and Materialize CSS, but what worked for me a couple times messing with Isotope is just putting it in the template:
<template name="someTemplate">
{{#if Template.subscriptionsReady}}
the html you want to use and have the script work on
<script>
the jquery init function
</script>
{{#/if}}
</template>
Just ran into this issue myself. I hope there is a non-hacky answer out there. Seems like it should be a simple thing. I hope this issue does not turn into a deal-breaker for materialize CSS.
Just to document further:
Some people suggested UI.body.rendered()
Though this will fail. Even with a timeout.
Still perplexed there is not way to do the equivalent of: on document ready.