Why is the el undefined on a page refresh or page load? Is it because the el does not exict?
class ListView extends Backbone.View
className: 'channels-list'
el: '#main'
initialize: ->
console.log @el
# undefined
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The element needs to be a tag name or element that already exists in the DOM. When a new view is created the
_ensureElementfunction is called:To avoid this place the script tag below the element tag or wait for the document load event, for example using jQuery:
Or, as Vitaliy suggested, rest
.elin theinitializefunction.