Created
October 23, 2014 13:54
-
-
Save knownasilya/024496388b8c849dec29 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
var DynamicView = Ember.ContainerView.extend(Ember._Metamorph, { | |
childViews: [], | |
viewChanged: function () { | |
var viewName = this.get('viewName'); | |
var view = this.container.lookup('view:' + viewName); | |
if (view) { | |
this.clear(); | |
this.pushObject(view); | |
} | |
}.observes('viewName').on('init') | |
}); | |
Ember.Handlebars.registerBoundHelper('dynamic-view', Ember.Handlebars.makeViewHelper(DynamicView)); |
Also, {{view}}
doesn't work with dynamic view names: http://emberjs.jsbin.com/wifido/edit?html,js,output
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
viewChanged
doesn't fire after the initial init fire when using{{dynamic-view viewName=myView}}
. But{{log myView}}
works just fine.This is using 1.7.
Note: I know
Ember._Metamorph
is private, but there is no good alternative. I'm assuming that's what has changed.