698
Views
4
Comments
Solved
Eventing from JavaScript
Question

I am building a JS library from which I need to trigger an event. Currently it is only possible to trigger an event from a webblock. How can I call a method of a web block from Javascript client action. 

2024-12-19 12-19-39
Amal
 
MVP
Solution

Hello Siya, 

You will find inspiration from Firebase component,  FirebaseReciever web block. (This is using jquery) 

One approach to achieve what you need using javascript is  explained below 

Step 1: Create a web block with Events you wish to trigger 

Step 2: Implement a custom listener with a getter & setter on a javascript object. 

Step 3: In the Initialize() of the web block register for a callback 

Step 4: Set the value from your javascript when you wish to trigger the event. 

Step 5: When the callback is fired in the web block, hook it to an action in the web block that can trigger the event. 

Check this link on how to implement the custom listener.  

Hope this helps. 

2018-08-06 13-40-17
Ramakrushnarao Seera

Hi Siya,

If i understand question correctly, you can run the client action from javascript like below.

If you are looking to trigger event from script. Try to put that event in action and trigger that action from javascript.


Regards,

Rama

2020-11-10 23-58-16
Raphael Ranieri
 
MVP

Hi Siya,

Take a look at this component.

It may help you understand how to do what you want.


Cheers and Regards,

RR :)

2024-12-19 12-19-39
Amal
 
MVP
Solution

Hello Siya, 

You will find inspiration from Firebase component,  FirebaseReciever web block. (This is using jquery) 

One approach to achieve what you need using javascript is  explained below 

Step 1: Create a web block with Events you wish to trigger 

Step 2: Implement a custom listener with a getter & setter on a javascript object. 

Step 3: In the Initialize() of the web block register for a callback 

Step 4: Set the value from your javascript when you wish to trigger the event. 

Step 5: When the callback is fired in the web block, hook it to an action in the web block that can trigger the event. 

Check this link on how to implement the custom listener.  

Hope this helps. 

2019-01-07 16-04-16
Siya
 
MVP

Thanks Amal. That helped.

Thanks Raphael Ranieri and Ramakrushnarao Seera for your support





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