187
Views
4
Comments
Solved
Button multiple on click event

Hello,

Is it possible to have multiple on click event for a button. Currently, my button brings me to another page but I also want the on click event to trigger a client action. But I cant set another onclick event.

Any suggestions? Thank you

2023-10-21 19-42-11
Tousif Khan
Champion
Solution

Hello

You can trigger the button on click event using javascript


document.getElementById("Btn").addEventListener("click", RunAction);

function RunAction() {

$actions.GlobalClientAction()  // this is your client action

}

I hope this will help

Best Regards 

Tousif Khan

UserImage.jpg
Low Nico

Hello Tousif Khan,

Thank you so much for your help, but would it be possible for you to provide a sample oml on how to do this? I am not good with javascript and where to use it . Thank you!

2021-10-01 12-43-46
N_SG
Solution

Hi @Low Nico 

You can directly call your client action in javascript;

Eg: $actions.YourClientActionName();

I have attached the OML, Please refer to it. 
Also see the Demo for the same Here.
Hope it helps!

Regards
N_G

CallClickEvent.oml
UserImage.jpg
Low Nico

Thank you N_G! This helped alot ! I appreciate it!

2023-10-21 19-42-11
Tousif Khan
Champion
Solution

Hello

You can trigger the button on click event using javascript


document.getElementById("Btn").addEventListener("click", RunAction);

function RunAction() {

$actions.GlobalClientAction()  // this is your client action

}

I hope this will help

Best Regards 

Tousif Khan

UserImage.jpg
Low Nico

Hello Tousif Khan,

Thank you so much for your help, but would it be possible for you to provide a sample oml on how to do this? I am not good with javascript and where to use it . Thank you!

2021-10-01 12-43-46
N_SG
Solution

Hi @Low Nico 

You can directly call your client action in javascript;

Eg: $actions.YourClientActionName();

I have attached the OML, Please refer to it. 
Also see the Demo for the same Here.
Hope it helps!

Regards
N_G

CallClickEvent.oml
UserImage.jpg
Low Nico

Thank you N_G! This helped alot ! I appreciate it!

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