254
Views
5
Comments
Solved
Trigger Action with a "built" HTML link
Question

Hi OS Community,

I am building a tree using graphing library. In each node of the tree I define the text, image etc using HTML. In each node I also want a link which triggers a client action (the action having one parameter passed into it). What is the best way to do this. For example i want to add something similar to my node <a href=MyAction(2211)> Click me </a> where MyAction is some kind of Client Action. Can be an onclick too. 

If there was a way to reference a block (where the content of the block was a link and the block contained the client action) via HTML then that could work as well.

I look forward to your ideas,

Rob

2018-10-18 08-34-00
Eric Bulters
 
MVP
Solution

You can create an OnReady event on your page. Add a Javascript block and define a function that you call with your onclick event. And in that function add the action you want to create pre-pended with "$action."


function MyClickFunction(){
	$action.MyActionHere();
}


Kind regards,
Eric

2021-02-18 12-29-06
António Pereira
Champion

Hi Robert,

Did you explore the option to add an event to the link and then call the Client Action? Or your use case is different?

Cheers,

António Pereira

UserImage.jpg
Robert Milliken

Hi Antonio,

Yes, this is a different situation. In an expression i am writing the html manually. I'm not using the Outsystems link widget.  Something like this

Node Contents expression  = "<div class='node-title'>Title</div><div class='node-content'>Description</div><a href=myActionHere()>Click me</a>"

Where myActionHere() is, that should be the name of the client action.

Thanks for your help though :)

Rob


2021-09-08 12-52-36
Dimitri Miller

Hi Robert,

did you find a solution?


Best regards

Dimitri

2018-10-18 08-34-00
Eric Bulters
 
MVP
Solution

You can create an OnReady event on your page. Add a Javascript block and define a function that you call with your onclick event. And in that function add the action you want to create pre-pended with "$action."


function MyClickFunction(){
	$action.MyActionHere();
}


Kind regards,
Eric

UserImage.jpg
Robert Milliken

Thanks All, yes the way I solved this was to use a javascript action to trigger my client action.


Thanks
Rob

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