Example of changing view through attach/detach
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
_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 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