title: Knockout Delay when updating Observables (w fiddle)
body: <p>I have a list of items that can be edited one at a time.  When editing, if the user clicks anywhere outside of the input EXCEPT for a cancel button, the data should save.  </p>
  
  <p>I have this working, but there's a slight delay in canceling the save because the "blur" event is registered before the Cancel button click.  I was wondering how I can eliminate this delay (perhaps by somehow detecting the Cancel first), or if I should rework the way this is currently scripted.  I'm open to any suggestions.  </p>
  
  <p>VM Code: </p>
  
  <pre><code>function PersonViewModel(name) {
      // Data
      var self = this;
      self.name = ko.observable(name);
      self.editing = ko.observable(false);
      self.oldName = ko.observable();      
      // Behaviors
      self.edit = function() { 
          self.oldName(self.name());
          self.editing(true) 
      }
      self.save = function() { 
          self.editing(false) 
      }
      self.cancel = function() { 
          self.name(self.oldName());
          self.editing(false) 
      }
  }
  
  ko.bindingHandlers.selected = {
      update: function(element, valueAccessor, allBindingsAccessor, viewModel, bindingContext) {
          var selected = ko.utils.unwrapObservable(valueAccessor());
          if (selected) element.select();
      }
  };
  
  ko.applyBindings(new PersonViewModel("Bert Bertington"));
  </code></pre>
  
  <p>View: </p>
  
  <pre><code>&lt;button data-bind="click: cancel"&gt;CANCEL&lt;/button&gt;
  &lt;p&gt;
      Name: 
      &lt;b data-bind="visible: !editing(), text: name, click: edit"&gt;&amp;nbsp;&lt;/b&gt;
      &lt;input data-bind="visible: editing, value: name, hasfocus: editing, selected: editing, event: {blur: save}" /&gt;
  &lt;/p&gt;
  &lt;p&gt;&lt;em&gt;Click the name to edit it; click elsewhere to apply changes.&lt;/em&gt;&lt;/p&gt;
  </code></pre>
  
  <p>JSFiddle: </p>
  
  <p><a href="http://jsfiddle.net/RnCUd/21/" rel="nofollow">http://jsfiddle.net/RnCUd/21/</a></p>