0

I am getting this error:

Uncaught TypeError: Cannot read property 'trigger' of undefined

in my Backbone view. It is saying it the this in my updateModel function is undefined.

But I don't understand why because I use this all throughout the rest of the view with no issues. They are all recognized.

Here is the code block that has the issue. As you can see, I successfully use this elsewhere.

Why doesn't it work in my updateModel function?

events() {
    'click #moreData': 'renderMain',
},

render: function() {
    // bunch of code related to styling and changing css

    return this;
},

renderMain(e) {
    setTimeout(_.bind(this.loadData, this), 1);
},

loadData: function () {
    this.renderComponent(microPlane, {
        model: this.model, 
        updateModel: this.updateModel }, 
        '.modelLayout');
},

updateModel: function () {
    this.trigger('change', this.model);
}

I just can't figure it out :/

SkyeBoniwell
  • 6,345
  • 12
  • 81
  • 185

0 Answers0