Is there a built-in way to set the number of decimal places of numbers when displayed (e.g. Text component)? The ‘create text with’ logic block is the only way I see to explicitly convert, but no way to set the display precision.
The 15 decimal places of lat and lng are getting ‘painful’!
A simple solution is to use a little JS to process the number.
Add logic for the
Content Logic handler of your
Text component. Here’s mine:
Custom Code block does the following:
Here’s the same code from the screenshot above:
Finally, a demo page:
Hope this helps.
Thanks Mark, that works; adding a ‘precision’ argument allows setting the number of decimal places.
Mark, where do I find the custom code block I built? I don’t see it in a list anywhere (like you do with custom functions).
I can copy the custom code block to a new event on the same page, but can’t copy to another page. What am I missing?
Custom code block will be in the logic where you built it. It will not appear in any lists.
Makes the scope pretty limited. However, seems the custom code block can be ‘wrapped’ in a custom function, giving container scope.
Any problems with this workaround?
That’s the way to go when you add code/logic meant for reuse.