Reputation: 2191
Question: I have code that works like this: BottomPaneView
initialize: function() {
...
this.childView = null
...
this.listenTo(this.childView, "findUnit", this.findUnit);
}
in another function,
{
...
this.childView = new TrackingView(...);
this.childView.render()
...
}
The last line in initialize throws "Uncaught TypeError: Object [object Object] has no method 'listenTo' ". Doesn't this refer to a View object?
Thanks!
Upvotes: 3
Views: 1946
Reputation: 2191
Ok, so the problem was I was using v0.9.0, and backbone didn't implement listenTo until 0.9.9. I updated to v1.0.0 and everything worked.
Note that before this, I moved the problem line below the this.childView.render()
in the second function to make sure the argument was initialized. I don't know if what I was doing initially would have worked.
Upvotes: 10
Reputation: 10743
The this.childView
must be an instance of Backbone.View
. Do a console.log
before the binding statement to check this.
Upvotes: 1