Select to view content in your preferred language

Emit not sent

2201
11
11-24-2021 11:47 AM
LefterisKoumis
Frequent Contributor

I am trying to modify the Screening widget. In one of its subfolders, "drawtool" in the file drawtool,js it emits the completion of the draw by using:

 

 

this.emit("onDrawComplete", [graphics]);

 

 

to the widget.js

 

 

this.own(on(this._drawTool, "onDrawComplete", lang.hitch(this, function (graphics) {
        this._initToCreateAOIBuffer(graphics);
      })));

 

 

I created my own file under the drawtool folder and I need to emit the same event from that file:

 

this.emit("onDrawComplete", [thePMPTgraphic]);    

 

However, the emit is not working. The issue is not the thePMPTgraphic,  since it was tested. 

Any ideas why the emit works in drawtools.js and not in the custom file? I have other functions in the custom file and are working properly.

0 Kudos
11 Replies
RobertScheitlin__GISP
MVP Emeritus

@LefterisKoumis 

Have you added the 

'dojo/Evented' module to your define array and the declare array like the drawTool.js file has? 
this.emit comes from that module.
 
0 Kudos
LefterisKoumis
Frequent Contributor

THanks Robert. The Evented module is present and is still not working. 

 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

@LefterisKoumis 

and you are sure Evented is part of your declare array too?

return declare([BaseWidget, _WidgetsInTemplateMixin, Evented], {
0 Kudos
LefterisKoumis
Frequent Contributor

Positive.

LefterisKoumis_0-1637787284746.png

 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

@LefterisKoumis

OK that looks good so it must be the listener then.

 

      this.own(on(this._drawTool, "onDrawComplete", lang.hitch(this, function (graphics) {
        this._initToCreateAOIBuffer(graphics);
      })));

 

The above code is only listening for the onDrawComplete event on the this_drawTool. So have you modified the widget.js to listen to the event on your custom component?

0 Kudos
LefterisKoumis
Frequent Contributor

I declared my component

 

 

'./drawTool/Screening_pmtools',
-----
], function (
----
Screening_pmtools,
-----

 

 

then I called it:

 

 

 this._drawPM = new Screening_pmtools()
      this.own(on(this._drawPM, "onDrawComplete", lang.hitch(this, function (graphics) {
        console.log(graphics)
        this._initToCreateAOIBuffer(graphics);
      })));

 

LefterisKoumis_0-1637790379964.png

 

 

 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

hmm... Have you tried to console.log you component out to see if it is what it's suppose to be?

this._drawPM = new Screening_pmtools();
console.log(this._drawPM);
0 Kudos
LefterisKoumis
Frequent Contributor

I did now and it is empty. I don't understand why it is empty since it is declared properly as shown in previous posting.

 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

does your "Screening_pmtools" constructor function have any arguments?

 Try putting some console.log or break points in your "Screening_pmtools"

0 Kudos