作者:tha1es | 来源:互联网 | 2023-05-18 18:45
ImnewtojQuery-uiandhavingaprobleminitializingajquery-ui-slider.Imtryingtocreateasl
I'm new to jQuery-ui and having a problem initializing a jquery-ui-slider. I'm trying to create a slider having min and max values.
我是jQuery-ui的新手,在初始化jquery-ui-slider时遇到了问题。我正在尝试创建一个具有最小值和最大值的滑块。
The slider should only have one handle, which should be initialized at some value, but somehow it is always set to max. I have however a span element in which I write the actual value of the slider and the value in this span is initialize correctly.
滑块应该只有一个手柄,应该初始化一些值,但不知何故它总是设置为最大值。我有一个span元素,我在其中写入滑块的实际值,并且此范围中的值正确初始化。
I initiate the slider as follows:
我按如下方式启动滑块:
jQuery("#slider-range-min").slider({
range: "min",
min: 3,
slide: function( event, ui ) {
jQuery("#length").text(ui.value);
}
});
The dialog in which the slider is embedded is initiated like this:
嵌入滑块的对话框启动如下:
jQuery(".config_length").live('dblclick',function() {
jQuery("#length-form").find("input[name=referer]").val(this.id);
var max = jQuery(this).find("input[name$='_param']").val();
var value = jQuery(this).find("input[name$='_value']").val();
jQuery("#slider-range-min").slider("option","max", max);
jQuery("#slider-range-min").slider("option","value", value);
jQuery("#length").text(value);
jQuery("#length-form").dialog("open");
});
'#slider-range-min' is the id of the slider, '#length-form' is the id of the dialog and '#length' the id of the span. Both variables 'max' and 'value' have the correct values (controlled with Firebug).
'#slider-range-min'是滑块的id,'#length-form'是对话框的id,'#length'是span的id。变量'max'和'value'都具有正确的值(由Firebug控制)。
If for example 'max' is set to 250 and 'value' to 100, the value in the span would be 100, the handle on the slider would be at the right-most position (which should be 250?), but as soon as I click on the handle the value in the span will change to 249.
例如,如果'max'设置为250而'value'设置为100,则span中的值将为100,滑块上的句柄将位于最右侧位置(应该是250?),但是要尽快当我点击手柄时,跨度中的值将变为249。
Edit
The Problem only occurs when the 'max' value is bigger then 100 (which is the default value for the max). Moreover it seems that order in which I set 'max' and 'value' also seems to influence the behaviour.
只有当'max'值大于100(这是max的默认值)时才会出现问题。此外,似乎我设置'max'和'value'的顺序似乎也影响了行为。
What am I doing wrong?
我究竟做错了什么?
2 个解决方案