ember.js - Ember model find records without server request -
i have ember model category:
export default ds.model.extend({ name: ds.attr('string'), img: ds.attr('string'), url: ds.attr('string'), cnt: ds.attr('number'), // parent_id: ds.belongsto('category', { // inverse: 'children', // async: true // }), parent_id: ds.attr('string'), // children: ds.hasmany('category', { // inverse: 'parent_id', // async: true // }), children: ds.attr(), isselected: false, isexpanded: false, haschildren: function() { return this.get('children').get('length') > 0; }.property('children').cacheable(), isleaf: function() { return this.get('children').get('length') == 0; }.property('children').cacheable() });
in index route have:
export default ember.route.extend({ model: function() { var store = this.store; return ember.arrayproxy.create({ categories: store.find('category'), menutopcategories: store.find('category', { parent_id: 1 }) }); } });
i'm using restadapter store.find send 2 requests server: categories
, categories?parent_id=1
. have first request , filter through categories. tried store.all
- since saw reuses fetch data, can't manage apply filter.
i've rewritten menutopcategories , don't see new request:
menutopcategories: store.filter('category', function(category) { return category.get('parent_id') === "1"; })
my problem right root category (first one) without hardcoding parent_id.
Comments
Post a Comment