Skip to content

Instantly share code, notes, and snippets.

@rjakobsson
Created January 18, 2015 21:15
Show Gist options
  • Save rjakobsson/2a7ead7798899128350a to your computer and use it in GitHub Desktop.
Save rjakobsson/2a7ead7798899128350a to your computer and use it in GitHub Desktop.
Showing dependency on data attribute in Router.route, in order to get back button functionality
<template name="layout">
{{#ionBody}}
{{> ionNavBar class="bar-dark"}}
{{#ionNavView}}
{{> yield}}
{{/ionNavView}}
{{/ionBody}}
</template>
<template name="hello">
{{#contentFor "headerTitle"}}
<h1 class="title">Hello</h1>
{{/contentFor}}
{{#ionView}}
{{#ionContent}}
Go to: <ul>
<li>
<a href="data">With data</a>
</li>
<li>
<a href="nodata">Without data</a>
</li>
</ul>
{{/ionContent}}
{{/ionView}}
</template>
<template name="post">
{{#contentFor "headerButtonLeft"}}
{{>ionNavBackButton}}
{{/contentFor}}
{{#contentFor "headerTitle"}}
<h1 class="title">Post</h1>
{{/contentFor}}
{{#ionView}}
{{#ionContent}}
<p>Post</p>
{{/ionContent}}
{{/ionView}}
</template>
Router.configure({
layoutTemplate: "layout"
});
Router.route("/data/", {
data: function () {
return "data";
},
action: function () {
if (this.ready()) {
this.render('post');
}
}
});
Router.route("/nodata/", {
action: function () {
if (this.ready()) {
this.render('post');
}
}
});
Router.route("/", {
action: function () {
if (this.ready()) {
this.render('hello');
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment