On initialization, `allowDecimalPadding` option `'floats'` does not hide the decimal zeroes if set in the html attribute
See original GitHub issueCurrent behavior
If have this options to my “decimal” inputs:
decimal_autonumeric_options = {
modifyValueOnWheel: false,
digitGroupSeparator: '.',
decimalCharacter: ',',
decimalPlaces: 2,
maximumValue: 999999999999,
unformatOnSubmit: true,
allowDecimalPadding: 'floats',
decimalCharacterAlternative: ".",
formatOnPageLoad: true,
}
I initialize the inputs with:
AutoNumeric.multiple "input.decimal", decimal_autonumeric_options
Expected behavior
When raw value of a input is, for example: 150
It should show on input “150” on initalization and first show of the page.
But, actually shows “150,0”
Afer a mouseover/mouseenter event, the input becomes “150”, so, Autonumeric removes the zero decimal digit after mouseenter, exactly like we wants due option allowDecimalPadding: ‘floats’, but it behaves wrong on init.
What a did to fix this behavior was, adding a “fake” mouseenter event after initialization to format correctly:
// Fixer for decimal digits after initialization
$.each($('input.decimal'), function(name, element) {
var autonumeric_instance;
autonumeric_instance = AutoNumeric.getAutoNumericElement(element);
if (autonumeric_instance) {
return autonumeric_instance._onFocusInAndMouseEnterFunc(new Event('mouseenter'));
}
});
All the inputs will show correctly after that fixer.
¿Is this a bug or I have something wrong on my options?
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
How to handle floats and decimal separators with html5 input ...
I think what's missing in the answers above is the need to specify a different value for the step attribute, which has a...
Read more >WRITE - format_options - ABAP Keyword Documentation
In data type f, the mantissa is adjusted to this exponent by moving the decimal point and padding with zeroes. If exp contains...
Read more >autonumeric - npm
allowDecimalPadding, Allow padding the decimal places with zeros. If set to 'floats' , padding is only done when there are some decimals. true....
Read more >Floating point numbers - Manual - PHP
If the string is numeric or leading numeric then it will resolve to the corresponding float value, otherwise it is converted to zero...
Read more >https://raw.githubusercontent.com/BobKnothe/autoNu...
4.1.0-beta.22 + Fix issue #525 The `input` event is not fired on mouse wheel ... `allowDecimalPadding` set to `'floats'` when `decimalPlaces` is different ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We assumed when the decimal part value was equal to zero, that there was no need to bother with it, and it got concatenated while still having one or more
'0'
as a string. The assumption is now removed, and the fix is inv4.5.8
!@camilova I tested under Firefox and Chromium, and couldn’t reproduce the bug using the latest
4.5.7
version.Could you please provide a reproducible test case ?