views:

2426

answers:

1

Hi all I'm looking to implement the jQuery UI so that the slider bar fills one side of the bar with a color as you drag the handle along, sort of like a progress bar. Can anyone give me tips on how I might approach this problem?

Thank you in advance.

+2  A: 

I probably should have looked at the slider() documentation more closely. Here is a much easier way to do what I think you're looking for. It's already built into jQuery UI. The example below is taken directly from the jQuery slider() documention page which I linked to above. The key is the range property passed into the options. Giving this a value of "min" will cause the slider to fill the left side with a color.

The JavaScript:

$(function() {
    $("#slider-range-min").slider({
        range: "min",
        value: 37,
        min: 1,
        max: 700,
        slide: function(event, ui) {
            $("#amount").val('$' + ui.value);
        }
    });
    $("#amount").val('$' + $("#slider-range-min").slider("value"));
});

The markup:

<div id="slider-range-min"></div>
Dan Herbert
Would this be in addition or in replacement of the slider function?
Rio
@Rio, I've updated my answer. This one uses the slider() function. My previous version was used in replacement of the slider(), but the solution above should work much better.
Dan Herbert