Last active
August 29, 2015 14:17
-
-
Save mika76/691a32cb6a4711f6390f to your computer and use it in GitHub Desktop.
Knockout custom binding for jQuery Knob http://anthonyterrien.com/knob/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/aterrien/jQuery-Knob/issues/209 | |
ko.bindingHandlers.knob = { | |
init: function(element, valueAccessor, allBindings, viewModel, bindingContext) { | |
var local = ko.utils.unwrapObservable(valueAccessor()), | |
options = {}; | |
ko.utils.extend(options, ko.bindingHandlers.knob.options); | |
ko.utils.extend(options, allBindings.get('knobOptions')); | |
$(element) | |
.knob(options) | |
.trigger('configure', options); | |
}, | |
update: function(element, valueAccessor, allBindings, viewModel, bindingContext) { | |
var local = ko.utils.unwrapObservable(valueAccessor()), | |
options = {}; | |
ko.utils.extend(options, ko.bindingHandlers.knob.options); | |
ko.utils.extend(options, allBindings.get('knobOptions')); | |
$(element) | |
.trigger('configure', options) | |
.val(local) | |
.trigger('change'); | |
}, | |
options: { | |
min: 0, | |
max: 100, | |
step: 1, | |
angleOffset: 0, | |
angleArc: 360, | |
stopper: true, | |
readOnly: true | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment