jQuery ui 滑块值错误?

发布于 2024-09-15 01:34:50 字数 771 浏览 2 评论 0原文

示例代码: http://jsbin.com/eqile3/

这是一个带有 2 个手柄的滑块,1 个为 min,1 个为 min对于 max 和幻灯片事件,这些值被放入输入字段中。

请注意,当上下滑动最小手柄时,最小值为 11(尽管我将其设置为 10),但是当从最小位置向上滑动时,它会从 11 到 10,然后是 11。如果我向下滑动再次变为 12,然后是 11...

非常奇怪的错误,不确定原因在哪里?

另外,当最小句柄位于来自步骤 0 的第一步时(因此值为 10),然后我移动最大句柄,最小句柄的值会正确更新。 max-handle 有相反的问题。

示例中相关的javascript:

$(document).ready(function(){
  $('#clarityslider').slider({step:1,min:10,max:18,range:true,values:[10, 18]});  

  $('#clarityslider').bind('slide', function(ui, event){
    valuemin = $(this).slider('values', 0);
    valuemax = $(this).slider('values', 1);


    $(this).next().val(valuemax);
    $(this).prev().val(valuemin);
  });
});

Example code:
http://jsbin.com/eqile3/

This is a slider with 2 handles, 1 for min and 1 for max and on the slide event these values are put in the input fields.

Notice that when sliding the min-handle up and down, the min value is 11 (eventhough I set it to 10), but when sliding up from the min-position it goes from 11 to 10 and then 11. If I slide back down again it goes to 12 and then 11 ...

Pretty weird error, not sure where the cause lies?

Also, when the min-handle is on the first step coming from step 0, so the value being 10, and I then move the max-handle, the min-handle's value is updated correctly. The max-handle has the opposite problem.

The relevant javascript in the example:

$(document).ready(function(){
  $('#clarityslider').slider({step:1,min:10,max:18,range:true,values:[10, 18]});  

  $('#clarityslider').bind('slide', function(ui, event){
    valuemin = $(this).slider('values', 0);
    valuemax = $(this).slider('values', 1);


    $(this).next().val(valuemax);
    $(this).prev().val(valuemin);
  });
});

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

寄与心 2024-09-22 01:34:50

哇非常感谢你!这也确实对我有帮助,因为我遇到了完全相同的问题!

曾经

slide: function(event, ui) {
          var Oldvalue = $('#slider').slider("value");

并且更改

slide: function(event, ui) {
              var Oldvalue = ui.value;

Wow thank you very much! that really helped me as well, coz I had the exact same problem!

I had:

slide: function(event, ui) {
          var Oldvalue = $('#slider').slider("value");

and changed to

slide: function(event, ui) {
              var Oldvalue = ui.value;
风蛊 2024-09-22 01:34:50

确实很奇怪的价值观。这更加简单,并且就像一个魅力:

$(document).ready(function(){

    var valuemin = valuemax = 0;

    $('#clarityslider').slider({
        min:    10,
        max:    18,
        range:  true,
        values: [10, 18],
        slide:  function(event, ui) {
            valuemin = ui.values[0];
            valuemax = ui.values[1];
            $(this).next().val(valuemax);
            $(this).prev().val(valuemin);
        }
    });
});

祝你正在构建的东西好运!

Strange values indeed. This is more simplified and works like a charm:

$(document).ready(function(){

    var valuemin = valuemax = 0;

    $('#clarityslider').slider({
        min:    10,
        max:    18,
        range:  true,
        values: [10, 18],
        slide:  function(event, ui) {
            valuemin = ui.values[0];
            valuemax = ui.values[1];
            $(this).next().val(valuemax);
            $(this).prev().val(valuemin);
        }
    });
});

Good luck with what you are building!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文