Reputation: 7156
I am confused about why '''el''' is undefined here, and $el is defined.
The background is en experiment with CoffeeScript as follows:
class FastTodo.Views.AddTodoItem extends Backbone.View template: JST['todo_items/add_item'] el: $('#main') render: -> console.log("render") console.log($("#main")) console.log(@el) console.log(@) $(@el).html @template initialize: -> @render()
How can I render the view in this case?
Upvotes: 4
Views: 6332
Reputation: 4348
Try rewriting the element declaration to el: '#main'
I think that should work well for you.
By the way, according to your console log the jQuery element ($el) is empty as well. You must be declaring the view before the markup has been fully loaded. By giving el
the selector for the elements you make sure it will be fetched only when the document is ready (loaded).
Upvotes: 5