Mabeh Al-Zuq Yadeek
Mabeh Al-Zuq Yadeek

Reputation: 84

Is there an elegant way to refresh a given template with Iron Router?

Since my variables are not reactive and there are probably over 500 variables in my script, there is not feasable way I can make everything reactive right now.

So my question is, is there any way to make Iron Router refresh the current route/template when prompted? Right now, the only way I accomplish this is using document.location.reload(true);, but that is an ugly looking and very slow process.

Let's also say that I have a {{> yield}} element in my template: is there any way to just refresh that part without refreshing the entire page?

Upvotes: 1

Views: 78

Answers (1)

Thai Tran
Thai Tran

Reputation: 9935

You probably need to define a reactive variable (Session or ReactiveVar) and change the state of that variable. On your template, make an if wrapping the part you need to refresh. When you change the state, the part inside the if will be refreshed.

helpers:

h_checkToRefresh: function() {
   if (Session.get('count') > 0) return true;
   else return false;
}

template

{{#if h_checkToRefresh}}
   {{>yield}}
{{/if}}

Upvotes: 1

Related Questions