onAction method from html_area

In web client I have a number of html_area field elements that have the onAction property set to trigger methods when clicked. In NG client the methods don’t trigger at all, the onAction doesn’t fire. What am I missing?

Hi David,

I encountered a similar problem where I needed some html to trigger a function in Servoy and pass it specific data of the click into that function.
Turns out that the bootstrap label (not the data-label!) can handle html AND will trigger the onAction event.
Through the attribute ‘data-target’ you can pass your data, the click will find the nearest data-target attribute.
Be careful, the data can be empty, so make sure the onAction method will handle that situation.

<div data-target="myData">text to be displayed</div>

Hope this helps

Hi Marc,

Thanks for the pointer - I’m still trying to maintain web client and make it work for NG as well, so not sure how this fits but will see what I can work out!

Hi David,

I am not sure the HTML_AREA actually works with the onAction event. At least I have never be able to make that work. What I tend to do is to use a HREF in the HTML that calls a method like so:

<html><a href="javascript:myLocalFormMethod()">link text</a></html>

You need to set the HTML_AREA field to non-editable. Then on the onLoad of the form you need to tell Servoy that the HTML is safe or else the click is not registered. So you add the following in the onLoad:

elements.myHtmlAreaField.putClientProperty(APP_UI_PROPERTY.TRUST_DATA_AS_HTML, true);

Hope this helps.

Hi Robert,

Currently the html_area elements in web client do respond to the onAction event. I remember a time when they didn’t but that did change a while back and they’ve been working nicely recently. But not in NG Client! Thanks for the tips on including the link in the html - I do this already in some places and it looks like I will need to change them all over.

Dave