Created
November 18, 2012 00:59
-
-
Save JeffreyWay/4102251 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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); | |
} | |
}); |
+1 for the first approach for basically the same reason.
perform logic was simple
of-course 1st one because of the reason given by dilab.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Ditto dilab