Nick Nick - 1 month ago 18
jQuery Question

roundSlider plugin - unable to get starting value

I'm working on a project where i need to use this roundSlider plugin:
https://github.com/soundar24/roundSlider

And i'm trying to change the color of the track(

.rs-range-color
) with the value of the slider when it's created.

Basically, i'd like to use it so that it goes from green, to yellow, to red according to the value and appends a class (
temp-
) to
rs-range-color
.

I have it working on change event, but i'm not able to figure out how to get the start value.
I'm using this as an angular directive in my project.

Here's a quick example:
http://jsbin.com/zipizofeco/edit?html,css,output

Also, i checked the console and i'm actually adding tons of classes, not only the one that i need..

Thanks a lot for any help

Answer

I actually managed to solve this myself, here's how if other people is interested: http://jsbin.com/forayowibu/edit?html,output

i created a setColor() function

function setColor(value){
        var el = $('.rs-range-color');
                    var tempValue = parseInt(value);
                    el.removeClass();
                    el.addClass('rs-path');
                    el.addClass('rs-transition');
                    el.addClass('rs-range-color');
                    el.addClass('speed-' + tempValue);
      }

passing the value as a parameter, and then calling it on change event and on create event.

Comments