开发者

Parameterizing max value of a jQuery ui slider

开发者 https://www.devze.com 2022-12-27 10:50 出处:网络
I\'m trying to create this slider http://jqueryui.com/demos/slider/#rangemax Is it possible to parametrize the max开发者_StackOverflow社区 value?

I'm trying to create this slider

http://jqueryui.com/demos/slider/#rangemax

Is it possible to parametrize the max开发者_StackOverflow社区 value?

For ex:

$("#slider-range-max").slider({
            range: "max",
            min: 1,
            max: maxValue,
            value: 2,
            slide: function(event, ui) {
                $("#amount").val(ui.value);
            }
        });

Is it possible to pass maxValue value, when I click on something? After its been initialized? Not on document ready function, but even after that?


You can set the values at any time, for max you'd do this:

$("#slider-range-max").slider("option", "max", newValue);

You can see how to do this with all the options at the jQuery UI site. Here's an example:

$(".increaseMax").click(function() {
  var currentMax = $("#slider-range-max").slider("option", "max");
  $("#slider-range-max").slider("option", "max", currentMax + 1);
});


According to the page you gave in your question (click on Options and then max):

Get or set the max option, after init. 
  //getter
  var max = $( ".selector" ).slider( "option", "max" );
  //setter
  $( ".selector" ).slider( "option", "max", 7 );

Change 7 to any value/variable you want to set the new maximum value to.

0

精彩评论

暂无评论...
验证码 换一张
取 消