Add Events to Container Dynamically
Question
Application Type
Mobile

Hi,

I am building a Mobile application and I am aware that I can add onclick event on the below section. But is it possible if I would want to add the event dynamically without the need to set it at the below section first. And beside that in the Handler I need to call a specific Screen Action. 

If anyone can help, would greatly appreciated. 



mvp_badge
MVP
Solution

Hi Yudi,

Yes, you can dynamically add event listener to the container. I have created a sample for the mentioned use case. See this sample screen DynamicCntrEventListenerDemo

  • On Button click an onclick event listener is defined to the container element. 
  • A screen action will get invoked on the container onclick event.


Used JavaScript Snippet:

var containerEle = document.querySelector('#' + $parameters.ContainerId);

containerEle.addEventListener('click', function() {
    $actions.EventHandler(); // invoking screen action
});

Refer to the attached .oml file


Hope this helps you!


Kind regards,

Benjith Sam

MobileLabDynamicCntEvntListnr.oml

Hi Benjith,

Thanks. It works as intended


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.