Hello community,
i have a problem and i don’t know how to solve it.
I have a JQuery plugin called “Slick” (http://kenwheeler.github.io/slick/).
On the Template.helper Method i’m loading some data from a mongo db.
The problem is that the page will be rendered and after that the content will be filled, because the Collection.find() method works asynchron.
So the jquery plugin will not be called.
What can i do?
jQuery and reactivity are notoriously error prone for beginners. Look into template level subscript and sub-templates
<template name="outer">
{{#if Template.subscriptionsReady}}
{{>inner cursor=cursor}}
{{/if}}
</template>
<template name="inner">
<!-- display data -->>
</template>
Template.outer.onCreated(function(){
this.subscribe('collection');
});
Template.outer.helpers({
cursor() {
return Collection.find();
}
});
Template.inner.onRendered(function(){
// do the slick call
});