How to Load single model multiple time in model hook

//…route.js

    0
    down vote

    favorite

I want to fill up multiple drop-down from API like below where i have to pass type parameter like ‘department’,‘priority’ etc. It didn’t return expected result as using one model ‘lookup’ for multiple calls.Sometime returns data of both department and some time priority data only and other department drop-down does not have any record.

model(){ var _this=this; return Ember.RSVP.hash({ status: _this.fetchLookup(‘department’), priority: _this.fetchLookup(‘priority’), }); }, fetchLookup(type) { return this.store.query(‘lookup’, { LookupType: type }); }

Use setupController like this:

Thanks for your response broerse i am trying to load one model ‘lookup’ multiple times in model hook. I have analyzed the implementation again and found that issue is occurring because API is returning id field same(start from 1 to rows count) for each lookup calls. There is only one model ‘lookup’ hence in store it update and insert data accordingly. That’s why dirty record appears in drop down. There is any way to clear store before call as these are async requests that’s why UnloadAll also didn’t work?

//route.js

 import Ember from 'ember';

    export default Ember.Route.extend({
        model() {
                return Ember.RSVP.hash({
                    lookupCategory: this.fetchLookup('category'),
                    lookupGroups: this.fetchLookup('groups'),
                    lookupPriority: this.fetchLookup('priority')
                });
            },
            setupController: function(controller, model) {
                controller.set('lookupCategory', model.lookupCategory);
                controller.set('lookupGroups', model.lookupGroups);
                controller.set('lookupPriority', model.lookupPriority);
            },
            fetchLookup(type) {
                console.log(type);
                return this.store.query('lookup', {
                    LookupType: type
                });
            }
    });