title: Backbone View Assign Template to el
body: <p>Is it ok to assign the @template() to an @el like this:</p>
  
  <p>someview.js.coffee</p>
  
  <pre><code>class SomeView extends Backbone.View
    template: JST["app/templates/sometemplate"]
  
    events:
      'click' : 'onClick'
  
    initialize: -&gt;
  
    render: -&gt;
      @el = @template()
  
    onClick: -&gt;
      #do something
  </code></pre>
  
  <p>index.js.coffee</p>
  
  <pre><code>class IndexView extends Backbone.View
    initialize: -&gt;
      @collection.on('reset', @render, this)
  
    render: -&gt;
      $(@el).html('')
      for m in @collection.models
        view = new App.Views.SomeView(model: m)
        $(@el).append(view.render().el)
  </code></pre>
  
  <p>sometemplate.jst.hamlc</p>
  
  <pre><code>.someview_template
    .stuff_inside
  </code></pre>
  
  <p>The situation I'm in, the SomeView class is being wrapped with a div and it's making me lose the click event I want assigned directly on the '.someview_template' element. The way I can think to solve this is by reseting the @el = @template()... is that possible or the right way to do this? </p>
  
  <p>Is it the case that the @el of Backbone.View should always be the containing div, and the template should be only the elements contained within that div? Seems like it would be more basic if @el is automatically set to the root node found in the @template(). Should I just let the sometemplate.jst.hamlc contain only ".stuff_inside", then in SomeView set $(@el).addClass('someview_template'), that way I can be sure the events are assigned to that element?</p>
  
  <p>Thanks!</p>