title: How do I force knockout to rebind a custom binding?
body: <p>I would like to know how I can force a knockout binding to refresh it's value. Normally we use an observable and that way the binding can happen automatically when the observable changes. But in my case I have created a custom binding:</p>
  
  <pre><code>if (!ko.bindingHandlers.asyncHtml) {
  ko.bindingHandlers.asyncHtml = {
      init: function (element, valueAccessor) {
          var value = ko.utils.unwrapObservable(valueAccessor());
          var parameters = value.params.concat([function (data) {
              $(element).html(data);
          } ]);
  
          parameters.concat([function (data) {
              $(element).html('Unable to retrieve html.');
          } ]);
          value.source.apply(null, parameters);
      }
  }
  }
  </code></pre>
  
  <p>This is so that a function which performs an asynchronous JSON call can update the respective element (with the returned HTML) once the call completes. The element, a DIV in this case, looks like this:</p>
  
  <pre><code>&lt;div id="myDiv" data-bind="asyncHtml: {source: getHtml, params: [myId()]}"&gt;
  </code></pre>
  
  <p>My problem is that, another feature on this page can change database values that require <em>myDiv</em> to be updated as a result. I can probably find a complicated way to correct this problem but I was wondering if there was a simpler way where I can just force the binding to reapply?</p>
  
  <p>NOTE: getHtml is a function on my viewmodel which performs the JSON call to retrieve the HTML.</p>
  
  <p>Thanks </p>