onAction method from html_area

Forum to discuss the new web client version of Servoy.

onAction method from html_area

Postby drookwood » Tue Jun 04, 2019 4:04 pm

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?
David Rookwood

SAN Developer
drookwood
 
Posts: 276
Joined: Tue Nov 11, 2003 7:08 pm
Location: Somerset, UK

Re: onAction method from html_area

Postby mboegem » Tue Jun 04, 2019 6:16 pm

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.

Code: Select all
<div data-target="myData">text to be displayed</div>


Hope this helps
_____________________
Marc Boegem
Solutiative / JBS Group, Partner
• Servoy Certified Developer
• Servoy Valued Professional
• Freelance SAN Developer

Image
User avatar
mboegem
 
Posts: 1517
Joined: Sun Oct 14, 2007 1:34 pm
Location: Hoofddorp, The Netherlands

Re: onAction method from html_area

Postby drookwood » Thu Jun 06, 2019 10:05 am

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!
David Rookwood

SAN Developer
drookwood
 
Posts: 276
Joined: Tue Nov 11, 2003 7:08 pm
Location: Somerset, UK

Re: onAction method from html_area

Postby ROCLASI » Fri Jun 07, 2019 4:58 pm

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:
Code: Select all
<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:
Code: Select all
elements.myHtmlAreaField.putClientProperty(APP_UI_PROPERTY.TRUST_DATA_AS_HTML, true);


Hope this helps.
Robert Ivens
ROCLASI Software Solutions / JBS Group, Partner
SAN Developer / Servoy Valued Professional / Servoy Certified Developer
Twitter: @roclasi / @servoyforge
--
ServoyForge - Building Open Source Software.
PostgreSQL - The world's most advanced open source database.
User avatar
ROCLASI
Servoy Expert
 
Posts: 5313
Joined: Thu Oct 02, 2003 9:49 am
Location: Netherlands/Belgium

Re: onAction method from html_area

Postby drookwood » Mon Jun 10, 2019 10:09 am

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
David Rookwood

SAN Developer
drookwood
 
Posts: 276
Joined: Tue Nov 11, 2003 7:08 pm
Location: Somerset, UK


Return to Servoy NGClient

Who is online

Users browsing this forum: No registered users and 1 guest