Created
July 31, 2012 22:16
-
-
Save lvbreda/3221138 to your computer and use it in GitHub Desktop.
Hacky routing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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}); | |
}); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template name="hello"> | |
hello | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template name="index"> | |
home | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<title>Stackoverflow</title> | |
</head> | |
<body> | |
</body> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
how navigate to other page without lose session with this solution?