Skip to content

Instantly share code, notes, and snippets.

@duereg
Created November 6, 2012 07:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save duereg/4023196 to your computer and use it in GitHub Desktop.
Save duereg/4023196 to your computer and use it in GitHub Desktop.
Knockout jQuery Button Binding Handler
if (ko && ko.bindingHandlers) {
ko.bindingHandlers['jEnable'] = {
'update': function(element, valueAccessor) {
var value = ko.utils.unwrapObservable(valueAccessor());
var $element = $(element);
$element.prop("disabled", !value);
if ($element.hasClass("ui-button")) {
$element.button("option", "disabled", !value);
}
}
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment