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

查看:373
本文介绍了jQuery UI滑块 - 无法滑动到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);
    }
});

它开始时很好,但在我移动滑块后我无法将其恢复为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

这设置了ui.Value当我将它滑动到-1时为-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.

任何想法?

推荐答案

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

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天全站免登陆