You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice if Backbone.History.route() added new routes to the start of the handlers array (unshift) rather than the end (push). This would allow you to override previously set routes and allow the following application logic to work.
pdv.Controllers.App = Backbone.Controller.extend({
initialize: function(options) {
// create App model, collection, view
this.route('*path', 'all', this.checkPath);
},
createPath: function(stub) {
this.getData(stub, function(data) {
// Create model and add to collection
// Add callback directly to model
this.route(data.stub, data.stub, function() {
// execute logic to show page
model.set({showPage: true})
});
});
},
getData: function(stub, callback) {
// Get data from server
if (data) {
callback.call(this, data);
} else {
// show 404 page
}
}
});
The text was updated successfully, but these errors were encountered:
Thanks for the idea -- calling route() should definitely allow you to override previously-defined routes. I've patched Backbone at ac8c3dd, give it a spin and let me know what you think.
It would be nice if
Backbone.History.route()
added new routes to the start of thehandlers
array (unshift
) rather than the end (push
). This would allow you to override previously set routes and allow the following application logic to work.The text was updated successfully, but these errors were encountered: