how I use "publishData" and "onReceiveData" .
I use the samplewidgets WidgetCommunication(WidgetA,WidgetB)
when I click publish Data ,there was a mistake.
Does anybody have this working, and have any advice for me?
code:
Qiang,
Sure I have it working is several of my widgets.
In my eSearch widget I have a function like this (line 3):
_initDrawBox: function () {
aspect.before(this.drawBox, "_activate", lang.hitch(this, function(){
this.publishData({message: "Deactivate_DrawTool"});
}));
In my other widgets that I want to listen I have:
startup: function(){
this.inherited(arguments);
this.fetchData();
this.list.parentWidget = this;
},
onReceiveData: function(name, widgetId, data) {
if(data.message && data.message === "Deactivate_DrawTool"){
this.drawBox.deactivate();
}
},
If the widget is not open when the other widget publishes data then you have to call fetchData when the widget does start so that it looks for the data and calls the onRecieveData method.
I am not sure why you are having that error you are showing though.
thanks for your replay. it woks use your code.
Don't forget to mark this question as answered by clicking on the "Correct Answer" link on the reply that answered your question.