Reputation: 3306
In Meteor I'm using Backbone in order to provide routing for the different pages in my app. I currently have a profile and an administration page. When I go to the profile page it shows up just as it should, however when I go to administration Meteor falls back to the main page.
As a side-note, if anyone has a better pattern or best-practice for pages in Meteor feel free to share as this is quite cumbersome.
I use the following template to decide what page to show:
<template name="root">
{{> navbar}}
{{#if pageIs "profile"}}
{{> profile}}
{{else}}{{#if pageIs "administration"}}
{{> administration}}
{{else}}
{{> main_page}}
{{/if}}
{{/if}}
</template>
The pageIs method is as follows:
Template.root.pageIs = function(page){
console.log(Session.get('page'));
return page === Session.get('page');
}
And the following code in my Backbone router:
var ProtonRouter = Backbone.Router.extend({
routes: {
"profile": "profile",
"admin": "administration",
"administration":"administration"
},
profile: function () {
Session.set('page','profile');
},
administration: function (){
Session.set('page', 'administraion');
},
mainPage: function(){
Session.set('page',null);
}
});
The log statement in the pageIs method will log undefined a couple of times and then log the correct page, even on administration, however Meteor doesn't seem to reload the selected page anyway and the template still hits the last else-statement.
Upvotes: 17
Views: 9917
Reputation: 36940
UPDATE: Iron router is being deprecated in favor of Flow Router. There are strong indications that Flow Router will be supported as part of core Meteor in the future.
OUTDATED: The previously commonly used router was Iron Router:
At its release, Iron Router combined the efforts of the authors of the two most widely used meteor routers (meteor-router and mini-pages), and was the de facto offcial router for Meteor prior to Flow Router.
Upvotes: 25
Reputation: 6260
In the early days of Meteor the recommendation was to use Backbone for routing.
The router Andrew pointed out in his post, has become the most popular choice: https://github.com/iron-meteor/iron-router
A more minimalistic solution is flow router: https://github.com/meteorhacks/flow-router
To make an informed decsion which one to use, you can read about the differences of both routers.
Upvotes: 1
Reputation: 3019
Lot of people use this route system:
https://github.com/tmeasday/meteor-router
It's really easy to use and made for Meteor.
Upvotes: 9