How to refresh the purticuler widget when click on button

ramesh_r
Mega Sage

Hi All,

I have a crerated page and I created 3 widgets in that page now I want to refresh the particular widget when I click on the search button

 

find_real_file.png

2 REPLIES 2

vims
Kilo Expert

1. Write an on click function on search button.

2. Trigger an event using broadcast or emit from the on click function

3. In the other two widgets write a listener

4. When listener listens on event triggered using broadcast or emit update the scope of the widget.

SatheeshKumar
Kilo Sage

You need to use events to communicate between the widgets , below is an example of what you are looking. the below code will refresh the second widget based on button click of first widget:

you need add the same in your existing widgets .

Widget #1:

Create two buttons that upon click, will $broadcast an event called “customEvent” and pass an object.

HTML:

Client Script:

Widget #2:

Listen for the “customEvent” event, and when triggered, the callback function will update the text.

HTML:

Client Script:

The final results should look like this:

videotogif_2016-11-22_10-48-41