Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor Iron Router Wait for template to be rendered

Is there anyway to wait for template to be rendered and then execute certain function?

I have tried after and it doesn't work.

Router.map(function () {
  this.route('post', {
    path: '/posts/:ll',

    action: function () {
      this.render('home');
    },

    after: function () {
      var n = this.params.ll
       UI.insert(UI.render(Template[n]), document.getElementById("child"))
    }
  });
});

Turns out the child element doesn't exist yet because the 'home' template isn't yet rendered when the after function is fired.

Any suggestion or work around is highly appreciated.

like image 964
Bads Avatar asked Mar 22 '23 04:03

Bads


1 Answers

Can you do this:

action: function () {
  this.render('home');
  Template.home.rendered = function() {
    // ...
    Template.home.rendered = null;
  };
},
like image 127
sbking Avatar answered Mar 27 '23 15:03

sbking