Skip to content

Instantly share code, notes, and snippets.

@danielmackay
Created July 7, 2013 11:16
Show Gist options
  • Select an option

  • Save danielmackay/5943161 to your computer and use it in GitHub Desktop.

Select an option

Save danielmackay/5943161 to your computer and use it in GitHub Desktop.
Knockout jQuery button binding
ko.bindingHandlers.jqButton = {
init: function(element) {
$(element).button(); // Turns the element into a jQuery UI button
},
update: function(element, valueAccessor) {
var currentValue = valueAccessor();
// Here we just update the "disabled" state, but you could update other properties too
$(element).button("option", "disabled", currentValue.enable === false);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment