0
votes

I've trying to do something very similar to what was asked in this previous SO question, from a year ago: Dynamically choosing a view at runtime with Ember + Handlebars.

Basically I have a route and I want to load a different view based on the retrieved models data. As default_container is now deprecated I can't just append the view from setupController, which would be the ugly way of doing it. The referenced SO seems to imply I can reference the view in my model, which sounds like a good start, or better yet use a mixin to extend the model and achieve the same result, however I haven't been able to get either of these to work (I just get "Assertion Failed: Unable to find view at path 'model.view'")

Ideally I'd like to be able to do something like

{{view model.view contentBinding="??"}}

from my template but I could be way off and the code in the old SO relies on Em.getPath(this.get('constructor') + 'View') which I also believe is now deprecated...

Being new to ember and with append view now deprecated I'm finding it reasonably hard to add views and subviews with most of the official documentation using append. Or maybe I'm just not understanding view creation in ember at all...

Thanks!

1

1 Answers

0
votes

I'm not sure exactly what it is you're trying to do, but you could maybe try something like this:

App.YourController = Ember.Controller.extend({
  computedPropertyWithNameOfView: function(){
    return 'yourView';
  }.property()
})


{{render computedPropertyWithNameOfView}}

This should render a view which will change based upon the bound property. The property should match a controller as you would with a route, and will render it's corresponding view. IIRC the {{view}} hasn't learnt about the container yet.