jeudi 19 février 2015

Nested routes model emberjs

I have following router:



App.Router.map(function () {
this.resource('discount', {path: '/'}, function () {
this.route('show', {path: '/show/:discount_id'})
});


here are routes:



App.CategoryRoute = Ember.Route.extend({
model: function (params) {
return this.store.find('discountCategory', params.category_id)
}
})

App.CategoryIndexRoute = Ember.Route.extend({
renderTemplate: function () {
this.render('category/index'),
this.render('modal', {
outlet: 'modal',
});
},
model: function () {
var category = this.modelFor('category');
return this.store.find('discount', {category_id: category.get('id')});
},
});

App.CategoryShowRoute = Ember.Route.extend( {
renderTemplate: function () {
this.render('category_modal', {
outlet: 'modal',
});
this.render('category/show');
},
model: function(params)
{
return this.store.find('discount',params.discount_id);
}
});


and there is view:



<h1>Category/show</h1>
<div class="b-sales-coupons">
{{#each discount in controllers.categoryIndex.model}}
<a {{action 'showModal' discount}} href="#" data-toggle="modal" class="b-sales-coupons-element" data-target=".b-sales-modal">
{{#discount-list-item discount=discount testAction='testAction'}}{{/discount-list-item}}
</a>
{{/each}}
</div>


When I am opening directly end point url: /categories/54e263084d6163051b010000/show/54e500a84169722aec000000


ember doesn't handle parent models in view from controllers.categoryIndex.model


In inspector there is only api call for this code:



this.store.find('discount',params.discount_id)


How to force child controller handle parent models?


Aucun commentaire:

Enregistrer un commentaire