mesosteros
mesosteros

Reputation: 1519

Meteor page navigation without Iron Router

I have implemented Iron Router in a Meteor project however we would like to have page navigation without Iron Router, since we realized it takes over control of the html .

This is unwanted because we fear it might complicate our handling of Meteor. However seeing as it is pretty much the default way done, is it even possible to have page navigation without the Iron Router or a router package at all?

Upvotes: 0

Views: 660

Answers (1)

Christian Fritz
Christian Fritz

Reputation: 21384

I'm not sure I understand your concern about breaking reactivity, but you can definitely avoid routers if you want, simply by using things like UI.dynamic (http://docs.meteor.com/#ui_dynamic):

{{> UI.dynamic template=templateName [data=dataContext]}}

Choose a template to include dynamically, by name.

UI.dynamic allows you to include a template by name, where the name may be calculated by a helper and may change reactively. The data argument is optional, and if it is omitted, the current data context is used.

For example, if there is a template named "foo", {{> UI.dynamic template="foo"}} is equivalent to {{> foo}}.

The helper that decides which template to render could be a simple lookup of a session variable (e.g., Session.get('page')) and then changing the current template could be done by setting that variable (e.g., Session.set('page', "blog")).

Upvotes: 2

Related Questions