title: Backbone when to build logic into view vs having separate view
body: <p>So I know there are many ways for doing things in Backbone, but since I don't have the vast experience of many on here, I would like advice regarding a best approach.</p>
  
  <p>I have a basic CRUD app where I have a form for adding data and a form for editing data, which are essentially the same. And actually are attached to the same DOM element.</p>
  
  <p>So I could include the two forms into one view and serve the appropriate template, depending on whether the view has a model or not. Something like this:</p>
  
  <pre><code>var AddEditView = Backbone.View.extend ({
  el: $("#add"),
  template: $("editTemplate").html();
  render: function() {
      if (this.model) {
          var theTmp = _.template(this.template)
          this.$el.html(theTmp(this.model.toJSON()));
      }
      else {
          var theTmp = _.template($("#addTemplate").html());
          this.$el.html(theTmp);
      }
  },
  </code></pre>
  
  <p>});
  I think this would work however I might run into some sticky issues with any events (i.e. events being bound twice).</p>
  
  <p>Or I could create two completely separate views that would be attached to the same dom element and would toggle back and forth depending on the app state (way more lines of code).</p>
  
  <p>What would you all recommend in this situation. Is more logic in a view better or more lines of code and less logic in views?</p>