on 08-29-2023 12:19 PM
Hello SAP Community,
I was after a steer on where I am going wrong with a custom widget I am developing?
The actual widget works great however if I have multiple instances of it on the screen when I set the property of one of the instances it affects all instances.
All the widget does is create a div and populate it every second with the time so it's like a real-time clock, however I have added a couple of properties which are set from the builder *.js file of "offset" and "dst" to allow the user from the designer to 1. Set any offset (e.g +5 to give me the time in India) and 2. any Daylight Saving Time (e.g. +1 to give me BST).
As mentioned the widget works as expected until I change the value in the designer which bleeds into all instances of the control instead of just the one I am updating. I have attached the code to see if somebody could help me with this...
In your provided code, the issue you're facing where changes to properties affect all instances of your custom widget occurs because you are using global variables dst and offset to store the values of these properties. These global variables are shared across all instances of your custom element, which is why changing one instance's properties affects all instances.
To fix this issue, you should store the dst and offset properties as instance-specific properties within your custom element.
Thanks,
Lakshmi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
72 | |
9 | |
8 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.