Skip to content

Instantly share code, notes, and snippets.

@muhamed-didovic
Forked from JeffreyWay/backbone-router.js
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save muhamed-didovic/afbbc081816848c3c68d to your computer and use it in GitHub Desktop.

Select an option

Save muhamed-didovic/afbbc081816848c3c68d to your computer and use it in GitHub Desktop.
// Which do you prefer more?
// trigger event and get out
var vent = _.extend({}, Backbone.Events);
App.Router = Backbone.Router.extend({
routes: {
'show/:id': 'show'
},
show: function(id) {
vent.trigger('thing:show', id);
}
});
// Or, perform logic
App.Router = Backbone.Router.extend({
routes: {
'show/:id': 'show'
},
show: function(id) {
var thing = new Thing({ name: 'Joe'});
var thingView = new ThingView({ model: thing });
$(document.body).append(thingView.render().el);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment