TJR
TJR

Reputation: 6577

meteorjs - force iron-router to wait the render of all until waitOn finished

I am looking for a way to wait before rendering anything when a waitOn argument is given.

Currently it works perfectly with the recommended way:

  1. use onBeforeAction ('loading')

  2. use action : function (if (this.ready()) this.render())

  3. waitOn : function () {return [Meteor.subscribe()...]}

    So when rendering the routing template the render process waits. But when I include a Template in the main-template the "sub"-Template will be rendered BEFORE the waitOn options ends.

So what is the recommended way to tell the iron-router to wait for the waitOn ready-state before render all included templates and also all yield-sub-templates ?

Upvotes: 1

Views: 207

Answers (1)

yoK0
yoK0

Reputation: 325

For me this works great:

this.route('note',{
    path: '/note/:_id', 
    waitOn: function() { return Meteor.subscribe('notes')},
    data: function() { 
        if( this.ready() ){ this.render();
            return Notes.findOne(this.params._id);
        }else{this.render('loading') }}
});

No content flashing or anything.

But also would like to know of how the guru's deal with it.

Upvotes: 0

Related Questions