How to set up routes on Parse.com? Alternative to Parse.Router

What is the easiest way to integrate a router? This https://parse.com/questions/how-to-create-website-with-parse suggests adding to Backbone.js next to Parse.

How do I do this in the easiest way?

I wonder if the Parse team is planning the Parse.Router class :)

+7
source share
2 answers

An earlier answer is out of date. Parse JS SDK now includes a router. Use Parse.Router and Parse.history.

+6
source

So far, my approach is to include a script link to backbone.js (which you get from the site) right after underscore.js, as this is a requirement of backbone.js just like parse.js one, 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 create an instance of Backbone.Router, for example:

 $(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 ... 
+2
source

All Articles