Closed elbrus closed 11 years ago
The slider binding (and jQuery UI's slider widget) has separate 'value' and 'values' options. Only 'value' is bound two way. If you need multiple handles on your slider then use the 'widget' option and the 'change' event:
single handle: http://jsfiddle.net/7XCmL/1/ multiple handles: http://jsfiddle.net/jZCay/6/
Regards, G
Great, thanks!
Another option is to use the "event" binding available, e.g. below the jqueryui "slide" event is used:
<div id="price-slider-id" data-bind="slider: {
range: true,
min: 0,
max: max_possible_price,
values: price_values,
slide: price_slide
}">
</div>
self.min_price = ko.observable(0);
self.max_price = ko.observable(9999);
self.max_possible_price = ko.observable(9999);
self.price_values = ko.computed(function() {
return [self.min_price(), self.max_price()];
});
self.price_slide = function(event, ui) {
self.min_price(ui.values[0]);
self.max_price(ui.values[1]);
}
Indeed, that's the simplest solution, thanks!
The jsfiddle using this technique: http://jsfiddle.net/gvas/jZCay/7/
Hi,
I've checked slider sample: http://gvas.github.io/knockout-jqueryui/slider.html
It seems, that write function isn't working (it's not called at all). So you can change values in input fields, and that will affect slider. But if you'll try to slide, then input fields will stay the same.
Btw, really useful project ;)
Regards, elbrus