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.
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.
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
Take a look at this component.
It may help you understand how to do what you want.
Cheers and Regards,
RR :)
Thanks Amal. That helped.
Thanks Raphael Ranieri and Ramakrushnarao Seera for your support