简体   繁体   中英

jQuery-UI multi-range slider - fetch values

I am using this jQuery-UI plugin for my multi-range input. It works nice, except for one part, I can't fetch its values. Has anybody used this plugin? How do I fetch values to use them in my program? I can't seem to find method that fetches data. There is no documentation that describes how to do it.

var ranges_array = [
  {
    id: 1,
    startValue: 2000,
    endValue: 8000,
    color: "rgb(27, 64, 194)"
  }
];
//
$(function() {
  $('#budget-range').rangeSlider({
    min: 0,
    max: 10000,
    ranges: ranges_array
  });
});

When defining your rangeSlider, you can create rangeSlide events that can read the values of the slider using the ui parameter on the event:

$(document).ready(function() {
  var currentStartValue = '';
  var currentEndValue = '';

  $('#budget-range').rangeSlider({
    min: 0,
    max: 10000,
    ranges: ranges_array,
    rangeSlide: function(event, ui) {
      currentStartValue = ui.range.startValue; // set the current start value of the range
      currentEndValue = ui.range.endValue; // set the current end value of the range
    }
  });

  function logRangeValues() {
    console.log('Start value: ' + currentStartValue);
    console.log('End value: ' + currentEndValue);
  }
}); 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM