Uncaught TypeError: Object # & lt; Object & gt; does not have a 'set' method

advertisements

When i try set my 'content' to the customerList i'll get the error:

Uncaught TypeError: Object #Object has no method 'set'

Here is my code:

  App.TableController = Em.ArrayController.extend({
init: function() {
    this._super();
    this.getData();
},
getData: function() {
    $.get('data/customer.json', function(data) {
        var customerList = Ember.A([]);
        data.forEach(function(item) {
            var customer = App.overv.create({
                incidient: item.incidient,
                customer: item.customer,
                machine: item.machine,
                priority: item.priority

            });
            customerList.pushObject(customer);
        });
        this.set('content', customerList);

    });
}});

I I also tried it with App.router.tableController.set('content',customerList) but ember doesn't recognize the controller anymore. With 1.0.0 pre 2 this second example worked great. Now i try to figure out what i did wrong or probably understood wrong.


Keep a reference of this in a local variable _self. See code below.

App.TableController = Em.ArrayController.extend({
init: function() {
    this._super();
    this.getData();
},
getData: function() {
    var _self = this;
    $.get('data/customer.json', function(data) {
        var customerList = Ember.A([]);
        data.forEach(function(item) {
            var customer = App.overv.create({
                incidient: item.incidient,
                customer: item.customer,
                machine: item.machine,
                priority: item.priority

            });
            customerList.pushObject(customer);
        });
        _self.set('content', customerList);

    });
}});