Ember have a default setupController
where the controller.model
is setup, so if you override it you need to do:
setupController: function (controller, model) {
// setup the model
controller.set('model', model);
// setup other things
}
Also, when you get the model using this.get('controller.model')
an array like object is returned, called DS.RecordArray
and that array have instances of DS.Model
, that models isn't a plain javascript object, so if your $('#calendar').fullCalendar({ events: events });
expect a plain js object, you need to use model.toJSON()
in each item of the record array.
This is the updated code:
App.IndexRoute = Ember.Route.extend({
model: function () {
return this.store.findAll('eventList');
},
setupController: function (controller, model) {
controller.set('model', model);
}
});
App.IndexView = Ember.View.extend({
didInsertElement: function () {
var events = this.get('controller.model').map(function(record) {
return record.toJSON({ includeId: true });
});
$('#calendar').fullCalendar({
events: events
});
}
});
I hope it helps