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!
Solved! Go to Solution.
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.
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.
Thanks!