I have a template that has a nested view. The nested view in turn has its own nested view. The views should all be rendered under the same route and use their own specific models. The browse template does not have an associated model.
The templates look like this:
<script type="text/x-handlebars" data-template-name="browse">
{{render "category" category}}
</script>
<script type="text/x-handlebars" data-template-name="category">
{{render "sort" sort}}
</script>
<script type="text/x-handlebars" data-template-name="sort">
<ul>
{{#each m in model}}
<li>{{m.sortType}}</li>
{{/each}}
</ul>
</script>
I'm returning all the models I need under the browse route:
App.BrowseRoute = Ember.Route.extend({
model: function () {
var store = this.store;
return new Em.RSVP.Promise(function (resolve, reject) {
new Em.RSVP.hash({
category: store.find('category'),
sort: store.find('sort')
}).then(function (results) {
resolve({
category: results.category,
sort: results.sort
});
});
});
}
});
I have no problem attaching the category model to the category template this way, but I'm unable to attach the sort model to the sort template. The sort model data is being returned, I just cannot figure out how to associate it with the sort template. Is it because the sort template is nested two levels deep?
Thanks!
Aucun commentaire:
Enregistrer un commentaire