chaonextdoor
chaonextdoor

Reputation: 5139

Why can't "this.$el" be recognized in my Backbone.js app?

When I use this.$el in my backbone.js app, firebug always tells me this.$el is not defined. I have to switch to $(this.el) to refer to the jquery element. Is there any difference between these two methods?

Upvotes: 2

Views: 745

Answers (2)

Chris Baclig
Chris Baclig

Reputation: 543

(I'm assuming you are referring to the $el attribute on Backbone.View objects)

I had a similar problem that was because I was using an older version of Backbonethat did not support the $el attribute on Backbone.View objects. Try upgrading Backbone.js to 0.9 or greater.

Upvotes: 4

fguillen
fguillen

Reputation: 38802

this.$el is a cached version of $(this.el) check documentationt it should work in normal situations, never has failed to me. Backbone it self uses it several times.

I think you have your problem somewhere else.

Upvotes: 0

Related Questions