I have a php page that is loaded up via a get request and contains multiple params like: index.php?page=6&name=Virginia. Once the page is loaded I then initalize backbone and am using it to render views on a portion of the page. The problem is that the router appears to be taking my entire url and registering it so that in order to trigger a route I have to append the following to my links: . This works but it's ugly. I've tried changing the root parameter to Backbone.history.start but can't seem to get it to work right. I'm sure most people don't start backbone from a dynamic page with query params but any help is appreciated. I've tried various solutions from plugins to different regexes but to no avail.
0
votes
1 Answers
0
votes
Without pushState you can't do this at all. I would do something like:
var router = Backbone.Router.extend({
routes: {
'*url': 'defaultRoute'
},
defaultRoute: function(url) {
// just url argument and parse params out
}
});
That in fact would be the easiest in your case. And for params, you need a class with get, set, and delete methods, that's pretty simple and you can find a ton of examples.