I am using Ember, Ember Data, and Handlebars to display a timeline with a number of different types of models. My current implementation, though functioning properly, seems lik
I solved this by establishing my own convention using a mixin. A model corresponds to a view with a similar name. For example, an App.Design model instance corresponds to the view App.DesignView.
App.ViewTypeConvention = Ember.Mixin.create({
viewType: function() {
return Em.getPath(this.get('constructor') + 'View');
}.property().cacheable()
});
I mix this into my models...
App.Design.reopen(App.ViewTypeConvention);
App.Order.reopen(App.ViewTypeConvention);
...and iterate over a mixed collection like this:
{{#each content}}
{{view item.viewType tagName="li" contentBinding="this"}}
{{/each}}
This way, I avoid defining the convention explicitly in my models. Thanks to Gordon, I realized that the view could by specified using a property on an object. I would still really like to hear about the 'right' way to solve this problem.