public
Last active

Hacky routing

  • Download Gist
client.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
if (Meteor.is_client) {
var Router = Backbone.Router.extend({
routes: {
"" : "main",
":page": "main" //this will be http://your_domain/
},
main: function(page) {
document.body.innerHTML = "";
page = page?page:"index";
var frag = Meteor.ui.render(function () {
var i = Template[page]?Template[page]():"";
return i;
});
document.body.appendChild(frag);
}
});
var app = new Router;
Meteor.startup(function () {
Backbone.history.start({pushState: true});
});
}
hello.html
HTML
1 2 3
<template name="hello">
hello
</template>
index.html
HTML
1 2 3
<template name="index">
home
</template>
stackover.html
HTML
1 2 3 4 5 6 7
<head>
<title>Stackoverflow</title>
</head>
 
<body>
 
</body>

how navigate to other page without lose session with this solution?

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.