Why does Dijit popup persist after mouse-over event?

325
4
Jump to solution
09-25-2019 07:04 AM
JustinBridwell2
Occasional Contributor II

I have an application that needs a popup on a layer during mouse-over. I am trying to use the Dijit Popup

define(["dojo/_base/declare","esri/graphic","esri/layers/GraphicsLayer","esri/InfoTemplate",.."esri/lang","dojo/_base/url","dojo/_base/lang","dijit/TooltipDialog","dijit/popup","dojo/dom-style","dojo/domReady!" ],  function (declare, Graphic, GraphicsLayer, InfoTemplate, esriLang, Url, lang, TooltipDialog, dijitPopup, domStyle) {return declare([GraphicsLayer], {   ....

The popup does display during the listening event, but it never goes away when the user mouses over a new feature. I am trying to use the example from this demo, but something is not quite right. First here is the error I get:

Error: Tried to register widget with id==tooltipDialog but that id is already registered

And here is the code I am trying to apply in my app. Any suggestions on how to get this to work? ***Note: 'this.' is a GraphicLayer. Also, I am using api 3.29 (not the latest version - I am refactoring an old app). 

....        dialog = new TooltipDialog({            id: "tooltipDialog",            style: "position: absolute; width: 250px; font: normal normal normal 10pt Helvetica;z-index:100"        });        dialog.startup();         this.on("mouse-over", function (evt) {            var content = esriLang.substitute(evt.graphic.attributes);            dialog.setContent(content);             domStyle.set(dialog.domNode, "opacity", 0.85);            dijitPopup.open({                popup: dialog,                x: evt.pageX,                y: evt.pageY             });            //this.setInfoTemplate(options.infoTemplate || new InfoTemplate("GeoJSON Data", "${*}"));            function closeDialog() {                map.graphics.clear();                dijitPopup.close(dialog);            }        });
0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Esteemed Contributor

Justin,

   I don't see any mouse-out event that calls the closeDialog...

View solution in original post

4 Replies
RobertScheitlin__GISP
MVP Esteemed Contributor

Justin,

   I don't see any mouse-out event that calls the closeDialog...

JustinBridwell2
Occasional Contributor II

Doh! You're right Robert. I just added this after my "mouse-over" listener and it worked. Thanks!

this.on("mouse-out", function (evt) {
    dijitPopup.close(dialog);
});

0 Kudos
RobertScheitlin__GISP
MVP Esteemed Contributor

Don't forget to mark this question as answered by clicking on the "Mark Correct" link on the reply that answered your question.

JustinBridwell2
Occasional Contributor II

OK, it seems like its been marked as correct. Thanks again.

0 Kudos