Select to view content in your preferred language

Can A Widget Send Message to LayerList Widget?

2127
2
Jump to solution
05-12-2016 02:58 PM
LeiZhou1
Occasional Contributor

When I use 2 different publishData functions inside startup () of Widget A, I want to send out the message: ‘ABCD’. See codes below:

startup: function() {

this.inherited(arguments);

        this.publishData({ 

               message: 'ABCD'

      });     

        this.publishData({ 

              message: 'XYZ'

      }); 

} // start up ends here

Then I set up the onReceiveData function in Layer List widget as the following; I want to receive this signal 'ABCD' from Widget A and display it (I don’t want XYZ to be passed since it will be used for another function). See codes below:

onReceiveData: function (name, widgetId, data, historyData) { 

if (name === 'Widget A'&& data.hasOwnProperty(‘ABCD')) { 

alert("The Layer List Widget received the signal ABCD");

    this._clearLayers(); 

    this.showLayers(); 

        } //if ends here

)}

But I never see any alert pop up window coming out. Why cann’t my onReceiveData function in LayerList Widget receive this message ‘ABCD’ from Widget A? Many thanks!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Lei,

  If the data has already been published before the layerlist widget is open and listening then you need to add: this.fetchData(); to the startup function in the layerlist widget.

View solution in original post

2 Replies
RobertScheitlin__GISP
MVP Emeritus

Lei,

  If the data has already been published before the layerlist widget is open and listening then you need to add: this.fetchData(); to the startup function in the layerlist widget.

LeiZhou1
Occasional Contributor

Thanks!

0 Kudos