简体   繁体   English

jQuery UI slider - 不能滑动到 0

[英]jQuery UI slider - can't slide to 0

jQuery 1.3.2 / jQueryUI 1.7 / Slider jQuery 1.3.2 / jQueryUI 1.7 / Slider

$("#slider").slider({
    range: "min",
    min: 0,
    max: 40,
    value: 0,
    slide: function(event, ui) {
        CalculateOrder(event, ui);
    }
});

it starts off just fine, but after I move the slider I can't get it back to 0, ui.Value is 1 when i slide it all the way to the left.它开始时很好,但是在我移动 slider 后,我无法将其恢复为 0,当我将它一直向左滑动时,ui.Value 为 1。

I've tried setting我试过设置

min:-1

this sets the ui.Value to -1 when i slide it to -1, but when I'm at 0 the ui.Value is still 1.当我将 ui.Value 滑动到 -1 时,这会将 ui.Value 设置为 -1,但是当我处于 0 时,ui.Value 仍然是 1。

Any ideas?有任何想法吗?

What you want is to get the value when the slider has stop, not during the slide.您想要的是在 slider 停止时而不是在滑动期间获得值。 From my experience, the slide event will get you the previous position of the slider.根据我的经验,幻灯片事件将为您提供 slider 的先前 position。 Stop will give you the value of the slider where the user move it to.停止将为您提供用户将其移动到的 slider 的值。

$("#slider").slider({
    range: 'min',
    min: 0,
    max: 40,
    value: 1,
    step: 10,
    slide : function(event, ui){
        console.log("previous value:"+ $(this).slider('option', 'value'));
    },
    stop: function(event, ui){
        console.log("Current value:"+ $(this).slider('option', 'value'));
    }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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