Reputation: 1744
Suppose I have an ArrayController
:
CellarRails.SearchController = Ember.ArrayController.extend({
content: []
});
and a SearchRoute
:
CellarRails.SearchRoute = Ember.Route.extend({
model: function(params) {
console.log('MODEL HOOKED!!');
return CellarRails.Track.find(params);
}
});
and a find method in model:
CellarRails.Track.reopenClass({
find: function(params) {
...
some code
...
return result;
}
});
PROBLEM: The result array is returning properly, model hook is fired, but content of controller is undefined and it's length is 0, so what am I doing wrong?
Upvotes: 1
Views: 1656
Reputation: 23322
You should add the setupController
hook and setting the content to the model returned by your find()
operation:
CellarRails.SearchRoute = Ember.Route.extend({
model: function(params) {
console.log('MODEL HOOKED!!');
return CellarRails.Track.find(params);
},
setupController: function(controller, model) {
controller.set('content', model);
}
});
See here for a working demo.
Hope it helps.
Upvotes: 3