我使用jSlider来实现一个触摸友好的范围滑块,但我有两个问题:
- 我想设置$10的最小范围,但我似乎无法做到这一点。(换句话说,下限和上限之间总是至少有10美元。)
- 我不能得到最小的值格式正确为$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);
谁能提出解决这两个问题的方法? EDIT:
$(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);
});