Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update parse function to handle string with commas #318

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cericthered
Copy link

If you are using a format function like the example below, it formats large numbers with commas ("1,000") to have a clean, readable format. However, the commas are not handled by the javascript parseFloat function in the way that is needed, so you end up parsing a number that does not match the original, and it will end up setting a new value on the dial which is incorrect. This happens when you manually type a value into the textbox. It will format the value and output, but it looks like that trigger another change event, which values the value to get validated/parsed again. I added a check in the 'parse' function to remove commas if the value is a string.

//EXAMPLE FORMAT FUNCTION THAT ADDS COMMA FOR THOUSANDS SEPARATORS
'format': function (val) {
var formatted = addCommasToNumber(val); //for "1000", would return "1,000"
return formatted;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant