views:

174

answers:

1

Hello Developers,

I am trying to resolve an issue. When I put in stepping, lets say .01 everything works great. However, if it lands on 1 it prints 1 instead of 1.00, as well as 3.40 prints as 3.4.

I have added toFixed(2) in various places of ui.slider.js, but have not found the correct location to make this fix.

Can anyone shed light to this question.

Best Regards, Robert Cushing Developer: Brilliance.com

A: 

If I understand your question, you want to query the value of a slider and display it somewhere else in a specific format (the slider doesn't display the value anywhere). The point where you inject your formatting logic is after you query the slider and before you display it somewhere else (note: this means you do NOT edit ui.slider.js). Something like:

var value = $('#my-slider').slider('value');
var formattedValue = value.toFixed(2);
$('#my-span').text('Current Value: ' + formattedValue);

If you're attempting to do this inside the sliders change event, then the current value is provided to you as a parameter of your function. Example:

$('#my-slider').slider({
    change: function(event, ui) {
        var formattedValue = ui.value.toFixed(2);
        $('#my-span').text('Current Value: ' + formattedValue);
    }
});
Ken Browning
Thanks man! That did it
RobertC
You're very welcome. Feel free to upvote and/or accept as answer.
Ken Browning