jQuery-Knob icon indicating copy to clipboard operation
jQuery-Knob copied to clipboard

Prefixing $ in format function

Open chivalrousgaurav opened this issue 10 years ago • 4 comments

The format function works fine if you have to suffix anything like %, but if you prefix anything it breaks the code and you can no longer use mouse scroll to control the knob.

I used this:

$(".dial").knob({ 'min': 1 ,'max':500, format: function(v) { return "$" + v ; } });

chivalrousgaurav avatar Jul 15 '14 18:07 chivalrousgaurav

Has there been any update here or were you able to find a work around?

jarombrown avatar Nov 12 '14 22:11 jarombrown

Same issue here, can't find a way to make it work :( Did you by any chance ?

Dams591 avatar Dec 07 '15 10:12 Dams591

Same issue here.

format: function (value) {
    if (type == '$') {
        value = '$' + value.toLocaleString();
    }
    return value
};

Input: 30000 Output: $30,000

Cheers

marcoramires avatar Feb 25 '16 03:02 marcoramires

I believe this is very similar to another issue I fixed, with commas in the formatted value. See pull request #318. You would just need to update the code I added to remove anything except numbers before parsing.

cericthered avatar Feb 25 '16 04:02 cericthered