title: Using a KnockBack ViewModel, is there a way to create a computed observable from the underlying Backbone model's methods?
body: <p>Using a KnockBack ViewModel, is there a way to create a computed observable from the underlying Backbone model's methods?</p>
  
  <p>As an example, in javascript:</p>
  
  <pre><code>var MyModel = Backbone.model.extend({
          validate: function () {
              return this.get('name').length &lt; 0;
          }
      }),
      baseModel = new MyModel({name: 'foo'}),
      kbViewModel = kb.viewModel(baseModel),
      modelContainer = document.querySelector('#myModel');
  ko.applyBindings(kbViewModel, modelContainer);
  </code></pre>
  
  <p>and in the Knockout markup:</p>
  
  <pre><code>&lt;div id="myModel"&gt;
      &lt;div data-bind="css:{'invalid': !validate()}"&gt;
          &lt;input type="text" data-bind="value: name" /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>When I try to run this, I get the error:</p>
  
  <pre><code>Unable to process binding "css: function (){return {'invalid':!validate()} }"
  Message: validate is not defined
  </code></pre>
  
  <p>Am I doing something wrong, or do I need to create the observable in the ViewModel manually?</p>
  
  <pre><code>var MyModel = Backbone.Model.extend({
          validate: function () {
              return this.get('name').length &gt; 0;
          }
      }),
      MyKBViewModel = kb.ViewModel.extend({
          constructor: function (model) {
              kb.ViewModel.prototype.constructor.call(this, model);
              this.validate = ko.pureComputed(function () {
                  return this.name().length &gt; 0;
              }, this);
          }
      }),
      baseModel = new MyModel({name: 'foo', class: 'bar'}),
      kbViewModel = new MyKBViewModel(baseModel),
      modelContainer = document.querySelector('#myModel');
  
  ko.applyBindings(kbViewModel, modelContainer);
  </code></pre>
  
  <p>jsfiddles: <a href="https://jsfiddle.net/asgallant/nk3j3ogb/" rel="nofollow">without observable</a>, <a href="https://jsfiddle.net/asgallant/nk3j3ogb/4/" rel="nofollow">with observable</a></p>