Last active
August 29, 2015 14:06
-
-
Save knownasilya/25463f8cc7728d62b879 to your computer and use it in GitHub Desktop.
Dynamic view binding helper for Ember.js
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
var DynamicView = Ember.ContainerView.extend(Ember._Metamorph, { | |
childViews: [], | |
viewChanged: function () { | |
var viewName = this.get('viewName'); | |
var view = this.get(viewName) || this.container.lookup('view:' + viewName); | |
if (view) { | |
this.clear(); | |
this.pushObject(view); | |
} | |
}.observes('viewName') | |
}); | |
Ember.Handlebars.registerBoundHelper('dynamic-view', Ember.Handlebars.makeViewHelper(DynamicView)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment