Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Call Plugin within jquery-ui slider function

I am using a range-slider from jquery ui and want to call another plugin (autosize) from its slide function. But in this way it does not work:

$( "#slider-range" ).slider({
  range: true,
  min: 100000,
  max: 5000000,
  step: 100000,
  animate: true,
  slide: function( event, ui ) {
    $( "#range_max" ).val(ui.values[ 1 ])).autosizeInput();
  },
});

How to call the autosizeInput() on the #range_max input field?

like image 757
user1308302 Avatar asked Apr 27 '26 19:04

user1308302


1 Answers

Here's a work-around where I bind a function to the input event of the text box and trigger it when the slider is moved.

$("#slider-range").slider({
  range: true,
  min: 100000,
  max: 5000000,
  step: 100000,
  animate: true,
  slide: function( event, ui ) {
    $( "#range_max" ).val(ui.values[ 1 ]).trigger('input');
  }
});

$("#range_max").on("input", function() {
  $(this).autosizeInput();
});

Updated Fiddle.

like image 185
Yass Avatar answered Apr 30 '26 09:04

Yass



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!