Last active
December 20, 2015 18:18
-
-
Save brianjmiller/6174702 to your computer and use it in GitHub Desktop.
Example of changing view through attach/detach
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
_changeView: function (newView, options) { | |
console.log("app::_changeView"); | |
options = options || {}; | |
options.renderFirst = (typeof options.renderFirst !== "undefined") ? options.renderFirst : true; | |
if (this._currentView !== null && this._currentView === newView) { | |
console.log("app::_changeView - no change needed"); | |
return; | |
} | |
if (this._currentView !== null) { | |
this._currentView.$el.detach(); | |
} | |
this._currentView = newView; | |
if (options.renderFirst) { | |
this._currentView.render(); | |
} | |
this._containerNode.append(this._currentView.$el); | |
} |
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
handleContent: function (page) { | |
console.log("app::handleContent - page: " + page); | |
var view = this._views[page], | |
ViewCtr; | |
if (typeof view === "undefined") { | |
ViewCtr = this.contentViewConstructors[page]; | |
view = this._views[page] = new ViewCtr (); | |
} | |
this._changeView(view); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment