knockout.js Href binding Custom binding handler


Example

href binding is not native to KnockoutJS, so to get dynamic links use a custom binding handler:

<a data-bind="href: myUrl">link with dynamic href</a>
ko.bindingHandlers['href'] = {
  update: function(element, valueAccessor) {
    element.href = ko.utils.unwrapObservable(valueAccessor());
  }
};