title: Backbone.Model validation and isValid
body: <p>I have set up my model validation like below</p>
  
  <ul>
  <li>Full CoffeeScript Code: <a href="http://pastebin.com/3isZZke8" rel="nofollow">http://pastebin.com/3isZZke8</a></li>
  <li>Demo on JS Fiddle: <a href="http://jsfiddle.net/XKTnb/" rel="nofollow">http://jsfiddle.net/XKTnb/</a></li>
  </ul>
  
  <p><strong>Model's Validation</strong></p>
  
  <pre><code>class Todo extends Backbone.Model 
      validate: (attrs) -&gt; 
          errs = {}
          hasErrors = false
  
          if (attrs.title is "")
              hasErrors = true
              errs.title = "Please specify a todo"
  
          if hasErrors
              return errs
  </code></pre>
  
  <p><strong>Error related code in View</strong></p>
  
  <pre><code>class TodoView extends Backbone.View
  
      events:
          "keypress .editing input[name=todo]": "saveTodo"
          "keyup .editing input[name=todo]": "closeEdit" 
          "blur input[name=todo]": "clearErrors"
  
      initialize: -&gt; 
          ...
          @model.bind("change", @render)
          @model.bind("error", @handleError)
  
      saveTodo: (e) -&gt;
          if e.type is "keypress" and e.charCode isnt 13
              return
          @model.set("title": @$("input[name=todo]").val())
          console.log @$("input[name=todo]").val() + "...", @model.isValid(), @model.get("title")
          if @model.isValid()
              @closeEdit()
  
      closeEdit: (e) -&gt;
          if (e)
              if e.type is "keyup" and e.keyCode isnt 27 then return
          @$el.removeClass("editing") 
  
      handleError: (model, errs) -&gt;
          @clearErrors()
          @$("input[name=todo]").after($("&lt;span /&gt;", {
              class: "error",
              html: errs.title
          }));
          console.log "error handled"
  
      clearErrors: -&gt;
          @$el.remove(".error")
  </code></pre>
  
  <p>In <code>TodoView.saveTodo</code>, I check if the model is valid, if so, I expect <code>save</code> to be successful and want to get out of edit edit mode. However, it appears <code>isValid</code> is always <code>true</code>, maybe because validation occurs and thus model is not saved thus in a valid state?</p>
  
  <p><strong>UPDATE</strong></p>
  
  <p>Added link to JS Fiddle above. Try adding a todo, then try to make the todo blank. Notice it closes the edit mode although in code I had: </p>
  
  <pre><code>saveTodo: (e) -&gt;
      if e.type is "keypress" and e.charCode isnt 13
          return
      @model.set("title", @$("input[name=todo]").val())
      if @model.isValid() # model appears to be valid here!
          @model.save()
          @closeEdit() 
  </code></pre>
  
  <p>Now double click to go into edit mode, notice the error is there meaning the validation was done correctly</p>