3
votes

I'm using Iron Router for my Meteor routing. I have an app layout that looks something like:

 <template name="appLayout">
    {{> menu}}
    {{> yield}}
    {{> footer}}
</template>

Whenever I use the template helper <a href="{{pathFor route='profileView' id=user._id}}"></a> in my menu template, the entire app doesn't refresh or reload, it loads the template fine, we're good. It seems the issue arises when a pathFor is clicked in a template that's been loaded within the yield. How can I prevent the app from refreshing or reloading when trying to load these other templates? Why is it happening just from templates that are loading within the yield?

1
I don't know the answer to your question, but Iron-router is known to have many issues with refresh/reloading when data changes, most of the time due to the fact that the data is subscribed to in the router. I have myself gone crazy with iron-router and dropped it for flow-router. I would suggest you look into it before you get too deep into your app. - MrE
So, I've made the switch to FlowRouter after reading a bunch of comparisons between it and Iron Router. I seem to be having the same issue. - SeanWM
instead of pathFor, have you tried a click event and router.go call to the new page? i guess pathFor act like a a html tag and will call on the server to serve the page. - MrE
@MrE Yep, tried that. I've moved to FlowRouter and have the same issue. - SeanWM
you're going to have to post more of your code, because I use nested dynamic templates and have not seen this problem. - MrE

1 Answers

1
votes

Basically iron router reload the page when url change.

I think your id=user._id, is depends on any subscription on your route waitOn function. So when your user._id change in the route the iron router will reload the page with the current subscription.

For prevent reload you can use methods call for getting your desire output from the server.

Let me know if It's solve your issue or not.