0

我正在使用jSlider来实现一个触摸友好的范围滑块,但我有两个问题:

  1. 我想将最低范围设置为 10 美元,但我似乎无法做到这一点。(换句话说,下限值和上限值之间总是至少有 10 美元。)
  2. 我无法获得正确格式化为 $0 的最小值 - 它显示$不是$0(实际上我更喜欢它,$1但我也无法实现)。

我用我的滑块设置了一个 JSFiddle:http: //jsfiddle.net/v3gUg/9/

这里也是代码,供参考:

var options = { 
  from: 0,
  to: 500,
  round: 10, 
  heterogeneity: ['50/100', '75/250'], 
  scale: ["£0", '|', "£50", '|' , "£100", '|', "£250", '|', "£500"],
  limits: true,
  step: 10,
  format: { format: '£#' }, // Doesn't return 0 correctly. 
  skin: "round_plastic",
  onstatechange: function() { 
      // Check range here and return false if too small?
      // But return false doesn't seem to do anything. 
     return false;
  }
};
jQuery("#price-slider").slider(options);

任何人都可以提出解决这两个问题的方法吗?

4

1 回答 1

1

编辑:

       $(document).ready(function() { 

  var options = { 
      from: 0,
      to: 500,
      round: 10, 
      heterogeneity: ['50/100', '75/250'], 
      scale: ["$0", '|', "$50", '|' , "$100", '|', "$250", '|', "$500"],
      limits: true,
      step: 10,
      format: { format: '$#,' },
      skin: "round_plastic",
    callback: function() { 
      // if (range too small)
      //return false;
    },
  onstatechange: function( value ){
    var array = value.split(";");

    if(array[0] == array[1])
    {
      value = array[0]+";"+array[1];
      $(".holder").slider("value", p1, p2)
    }
  } 
    };
  jQuery("#price-slider").slider(options);

});
于 2013-01-08T11:27:54.743 回答