EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: kudoof on March 17, 2013, 08:38:54 AM



Title: How to change options (e.g., min, max) on the fly in the slider?
Post by: kudoof on March 17, 2013, 08:38:54 AM
 I wanted to change the min/max options of a slider when user enters a new value for the min/max, but in the documentation of easyui, its method 'option' only gets options and can not set. I also tried the following, but still did not work  :'(:
Code:
$("#min")[0].addEventListener("input", function(){
var v = $("#min").val();
if (v <= 5 ) { 
    $("#myslider").slider('destroy').end().slider({ 
        width: 300,
        mode: 'h',
        showTip: true,
        value: 5,
        min: v, 
        max: 10
    });
}
else {
     alert("out of bound(1-5): " + v);
}
}, false);


Title: Re: How to change options (e.g., min, max) on the fly in the slider?
Post by: stworthy on March 17, 2013, 07:59:28 PM
Please refer to this example http://jsfiddle.net/68Z7D/ that shows how to change 'min' property value on slider.


Title: Re: How to change options (e.g., min, max) on the fly in the slider?
Post by: kudoof on March 17, 2013, 10:47:32 PM
Exactly what I needed. Thanks!!!!


Title: Re: How to change options (e.g., min, max) on the fly in the slider?
Post by: kudoof on April 16, 2013, 06:03:01 PM
I found a subtle problem in the way I use it.  Changing the max is okay, but changing the min will cause the slider to malfunction.  I had to use min: Number(v) to make it work.

here:
http://jsfiddle.net/cFBVe/ (http://jsfiddle.net/cFBVe/)


Title: Re: How to change options (e.g., min, max) on the fly in the slider?
Post by: stworthy on April 16, 2013, 08:11:46 PM
Please download the updated slider plugin from http://www.jeasyui.com/easyui/plugins/jquery.slider.js to solve this issue.