Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Here is an example: <a href="http://jsfiddle.net/jearles/Dt7Ka/" rel="nofollow noreferrer">http://jsfiddle.net/jearles/Dt7Ka/</a></p> <p>I use a custom binding to integrate the jquery-ui slider and use Knockout to capture the inputs and calculate the net amount.</p> <p>--</p> <p>UI</p> <pre><code>&lt;h2&gt;Slider Demo&lt;/h2&gt; Savings: &lt;input data-bind="value: savings, valueUpdate: 'afterkeydown'" /&gt; &lt;div style="margin: 10px" data-bind="slider: savings, sliderOptions: {min: 0, max: 100, range: 'min', step: 1}"&gt;&lt;/div&gt; Spent: &lt;input data-bind="value: spent, valueUpdate: 'afterkeydown'" /&gt; &lt;div style="margin: 10px" data-bind="slider: spent, sliderOptions: {min: 0, max: 100, range: 'min', step: 1}"&gt;&lt;/div&gt; Net: &lt;span data-bind="text: net"&gt;&lt;/span&gt; </code></pre> <p>View Model</p> <pre><code>ko.bindingHandlers.slider = { init: function (element, valueAccessor, allBindingsAccessor) { var options = allBindingsAccessor().sliderOptions || {}; $(element).slider(options); $(element).slider({ "slide": function (event, ui) { var observable = valueAccessor(); observable(ui.value); }, "change": function (event, ui) { var observable = valueAccessor(); observable(ui.value); } }); ko.utils.domNodeDisposal.addDisposeCallback(element, function () { $(element).slider("destroy"); }); }, update: function (element, valueAccessor) { var value = ko.unwrap(valueAccessor()); if (isNaN(value)) { value = 0; } $(element).slider("value", value); } }; var ViewModel = function() { var self = this; self.savings = ko.observable(10); self.spent = ko.observable(5); self.net = ko.computed(function() { return self.savings() - self.spent(); }); } ko.applyBindings(new ViewModel()); </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload