Skip to content

Instantly share code, notes, and snippets.

@samandmoore
Last active August 29, 2015 14:15
Show Gist options
  • Save samandmoore/a59d4be4fd59884135ac to your computer and use it in GitHub Desktop.
Save samandmoore/a59d4be4fd59884135ac to your computer and use it in GitHub Desktop.
beforeRender
BaseRouter.extend({
'portfolio': new PortfolioRoute(),
// or the old way...
'home’: 'home'',
'login': loginFunction,
});
var PortfolioRoute = BaseRoute.extend({
prepare: function() {
this.promise = …;
return this.promise;
},
render: function() { … },
error: function() { … }
});
beforeRender: function() {
this.model = new Account();
return this.model.fetch();
}
onRender: function() {
this.preloadStart();
this.loadSomeDataWeNeed().then(this.preloadComplete);
},
loadSomeDataWeNeed: function() {
this.account = new Account();
return this.account.fetch();
},
preloadStart: function() {
// hide $el and show loading indicator
},
preloadComplete: function() {
// show $el and hide loading indicator
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment