jQuery UI 滑块 - 不能滑动到 0 [英] jQuery UI slider - can't slide to 0

查看:35
本文介绍了jQuery UI 滑块 - 不能滑动到 0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

jQuery 1.3.2/jQueryUI 1.7/滑块

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);
    }
});

它开始时很好,但在我移动滑块后我无法将其恢复为 0,当我将滑块一直向左滑动时,ui.Value 为 1.

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.

我试过设置

min:-1

当我将它滑动到 -1 时,这会将 ui.Value 设置为 -1,但是当我在 0 时,ui.Value 仍然是 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.

有什么想法吗?

推荐答案

您想要的是在滑块停止时获取值,而不是在滑动期间.根据我的经验,slide 事件会让你获得滑块的先前位置.停止将为您提供用户将其移动到的滑块的值.

What you want is to get the value when the slider has stop, not during the slide. From my experience, the slide event will get you the previous position of the slider. Stop will give you the value of the slider where the user move it to.

$("#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'));
    }
});

这篇关于jQuery UI 滑块 - 不能滑动到 0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆