-
-
Save neiltron/3140023 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
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.close(); | |
//create new view | |
this.currentView = view; | |
this.currentView.delegateEvents(); | |
$('div#homepage').html(this.currentView.render().el); | |
return this.currentView; | |
} | |
}); | |
Backbone.View.prototype.close = function () { | |
this.remove(); | |
this.unbind(); | |
this.undelegateEvents(); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment