1
 Follower
4
 Likes

Expose named widgets in Execute Javascript scope

Frontend
On our radar

If we need to manipulate a wdiget via javascript in a mobile app, we need to pass its id to the Execute Javascript as an input parameter. It would be easier to just have named widgets in the scope tree, and to be able to refer to the widget's id with a syntax such as $widgets.MyWidget.Id.

Created on 22 Feb
Comments (2)

Hi Leonardo,

Although I can understand why you'd want to have easy access to a widget's ID, I'd like to know better the actual use-cases you need it for and perhaps make those easier. Is it direct DOM manipulation? Setting event handlers? A lot of these can and should be done in other ways (without making use of JS custom logic).

Cheers,

Miguel

Hi Miguel. My use case specifically was to open/close accordion items programmatically. There is no API exposed to do that, so I ended up triggering a click event in the accordion title.

I had a few other use cases in the past, which could only be accomplished by using javascript:

  • Checking whether an input bound to an integer variable was filled in or just left blank (both would set the variable to 0). Requires to retrieve the value of the input via javascript. This could be fixed if there were a TypedValue runtime property on the mobile widget.
  • Focusing on an input automatically after clicking on a button to ease data entry.
views
271
Followers
1