What's the simplest way to integrate a Router? This https://parse.com/questions/how-to-create-website-with-parse suggests to add in Backbone.js next to Parse.
How do I go about doing that in the lightest fashion?
Wondering if the Parse team is planning a Parse.Router class :)
The earlier response is outdated. Parse JS SDK now includes a router. Use Parse.Router and Parse.history.
My approach so far is to include a script link to backbone.js (which you get from the site) right after underscore.js since it is a backbone.js requirement just as it is a parse.js one, like so
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="js/underscore-1.1.6.js"></script>
<script src="js/backbone.js"></script>
<script src="http://www.parsecdn.com/js/parse-1.0.10.min.js"></script>
<script src="js/myApp.js"></script>
And then creating a Backbone.Router instance like so
$(function() {
Parse.$ = jQuery;
// Initialize Parse with your Parse application javascript keys
Parse.initialize("YOUR_APPLICATION_ID", "YOUR_JAVASCRIPT_KEY");
// Router
var Workspace = Backbone.Router.extend({
routes: {
"help": "help", // #help
"search/:query": "search" // #search/kiwis
},
help: function() {
//
console.log("help");
},
search: function(query, page) {
//
console.log("search query is "+query);
}
});
this.Router = new Workspace();
Backbone.history.start();
// Models ...
// Views ...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With