Estoy usando jQuery 1.7.2 y jQuery UI 1.9.1. Estoy usando el siguiente código dentro de un control deslizante. (http://jqueryui.com/slider/)
Tengo una función que debería probar dos valores y, dependiendo de la diferencia entre los dos valores, reformatearlos (al lugar decimal apropiado). Si la diferencia es mayor que 10, analizaré el número entero. Si la diferencia es mayor que 5, debe mantener un decimal. Todo lo demás, me quedaré con dos decimales.
Cuando ingreso dos valores que tienen una diferencia de diez o menos, uso la función toFixed (). Y, en Firebug, veo un error:
TypeError: Low.toFixed is not a function
Low = Low.toFixed(2);
¿Hay algo simple que esté haciendo mal?
Aquí está mi código:
var Low = $SliderValFrom.val(),
High = $SliderValTo.val();
// THE NUMBER IS VALID
if (isNaN(Low) == false && isNaN(High) == false) {
Diff = High - Low;
if (Diff > 10) {
Low = parseInt(Low);
High = parseInt(High);
} else if (Diff > 5) {
Low = Low.toFixed(1);
High = High.toFixed(1);
} else {
Low = Low.toFixed(2);
High = High.toFixed(2);
}
}