Hi all, I am pretty new to Ember and i encountered a problem which I worked around but I am very curious about it. I have the following route:
export default Ember.Route.extend( {
model: function(params) {
this.store.unloadAll('apiary');
this.store.unloadAll('beehive');
this.store.adapterFor('beehive').set('namespace', 'api/v1/apiaries/' + params.apiary_name.replace(/ /g, "."));
var hives = this.store.find('beehive');
this.store.adapterFor('beehive').set('namespace', 'api/v1');
return Ember.RSVP.hash({
apiary: this.store.find('apiary', params.apiary_name.replace(/ /g, ".")),
beehives: hives
});
},
actions:{
showLineChart: function(type, beehiveId) {
var self=this;
self.controller.set('lineChartData', this.store.find('beehive_inspection', {by_beehive: beehiveId})); // returns nothing
this.store.find('beehive_inspection', {by_beehive: beehiveId}).then(function(a) {
self.controller.set('lineChartData', a.get('content')); //returns ok
});
}
} });
The model hook works just fine and returned all the data correctly. However when the showLineChart action is called (from a component) if I try to access the store again using store find without handling its response, the returned value is always empty although i can see the request is made in my back end. To get the data i had to handle the response and get its content. Any idea why this happens ?