Update parse function to handle string with commas#318
Open
cericthered wants to merge 2 commits intoaterrien:masterfrom
Open
Update parse function to handle string with commas#318cericthered wants to merge 2 commits intoaterrien:masterfrom
cericthered wants to merge 2 commits intoaterrien:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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;
}