Search code examples
javascriptjqueryjquery-uiknockout.jsjquery-ui-slider

update slider only after the slider stops


I have a knockout.js slider using jquery-ui slider.

<input id="ex2" data-slider-id="ex2Slider" type="text" data-bind="sliderValue: {value: borrowOrInvestAmount, min:0, max: 5000, step: 1, formatter:formatter2}, event: { change: $root.getInvestmentDetailsForBorrower }, valueUpdate:['afterkeydown','propertychange','input']" style="display: none;">

So I tried using value-update but did not work. Now when I click on the slider points without dragging it, it works normally and calls $root.getInvestment, but I want that to be called right after the slider stops being dragged.

Now when I drag the slider, it stops on all the points till it reaches its target.


Solution

  • I found out the error in my code I just wrote a bit too much in the valueUpdate, just writing this

    valueUpdate: 'afterkeydown'
    

    Instead of this

    valueUpdate:['afterkeydown','propertychange','input']
    

    Works perfectly!