Skip to content

Instantly share code, notes, and snippets.

@kokeroulis
Created August 13, 2013 06:50
Show Gist options
  • Save kokeroulis/6218481 to your computer and use it in GitHub Desktop.
Save kokeroulis/6218481 to your computer and use it in GitHub Desktop.
Assertion failed: an Ember.CollectionView's content must implement Ember.Array. You passed function () {
var sbList = Ember.Array();
this.channels.forEach(function(c) {
sbList.pushObject(ChannelsModel.find(c.id));
});
return sbList;
} application.js:727
Uncaught TypeError: Object function () {
var sbList = Ember.Array();
this.channels.forEach(function(c) {
sbList.pushObject(ChannelsModel.find(c.id));
});
return sbList;
} has no method 'addArrayObserver'
var utils = require('../utils.js');
var ChannelsModel = require('../models/channels.js');
var ChannelModel = require("../models/channel.js");
var ChannelsRoute = Ember.Route.extend({
model: function() {
return ChannelsModel.findAll().then(function(result) {
return Ember.Object.create({
channels: result,
subChannels: function() {
var sbList = Ember.Array();
this.channels.forEach(function(c) {
sbList.pushObject(ChannelsModel.find(c.id));
});
return sbList;
}
})
});
},
setupController: function(controller, model) {
controller.set('channels', model.get('channels'));
controller.set('subChannels', model.get('subChannels'));
}
});
module.exports = ChannelsRoute;
var utils = require('../utils.js');
var ChannelModel = Ember.Object.extend({});
ChannelModel.reopenClass({
find: function(channelId) {
utils.get('channel/' + channelId, function(response) {
return ChannelModel.create(response);
});
}
});
module.exports = ChannelModel;
var utils = require('../utils.js');
var ChannelsModel = Ember.Object.extend({});
ChannelsModel.reopenClass({
findAll: function() {
var channels = Ember.A();
//var channels = [];
var promise = Ember.Deferred.create();
utils.get('channels', function(response) {
response.channels.forEach(function(c, index) {
channels.pushObject(ChannelsModel.create(c));
if(index === channels.length -1) {
promise.resolve(channels);
}
})
});
return promise;
}
});
module.exports = ChannelsModel;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment