Skip to content

Instantly share code, notes, and snippets.

Created July 19, 2012 00:40
Show Gist options
  • Save anonymous/3139995 to your computer and use it in GitHub Desktop.
Save anonymous/3139995 to your computer and use it in GitHub Desktop.
movieDb.Router = Backbone.Router.extend({
routes:{
'': 'landPage',
'home': 'landPage',
'login': 'login',
'signup': 'signup',
'addmovie': 'addMovie'
},
landPage: function(p){
$('div#homepage').empty();
},
login: function(p){
new loginView();
},
signup: function(p){
new signupView();
},
// Movie form template, w/ dynamic action(add,update)
movieForm: function(action){
return new movieformView({type: action});
},
addMovie: function(p){
this.showView(this.movieForm('add'));
},
showView: function (view) {
//destroy current view
this.currentView.remove();
this.currentView.undelegateEvents();
//create new view
this.currentView = view;
this.currentView.delegateEvents();
$('div#homepage').html(this.currentView.render().el);
return this.currentView;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment