x-model.number inconsistent within a x-text calculation #2293
Replies: 1 comment 3 replies
-
It's more a js thing here. Your code is logically incorrect. In Js, the I assume you did that because you don't want to show 0 in the field and you prefer an empty input but, in that case, you need to cast the parameter to numbers when you build the operation (For example |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I have 3 x-model inputs using the number modifier, plus an x-text calculation to display the sum.
I have discovered this only works if the input are entered in the correct sequence. Specifically, until the first item in the expression has a value, the properties are treated as strings and concatenated instead.
The following Codepen demonstrates: To highlight the quirk, I deliberately coded the x-text in reverse order "C+B+A"
https://codepen.io/mortimercat/pen/bGrojrJ
Demo 1:
Enter A=1, B=2 - note the total says "21"
Enter C=3 - The total corrects itself to "6"
Delete C, the total now correctly shows 3
Demo 2: (
Enter C=1, B=2 - the total shows 3 - every thing is working
Beta Was this translation helpful? Give feedback.
All reactions