Close Dialog Popup on Hyperlink Click

1530
13
Jump to solution
08-10-2017 12:29 PM
deleted-user-1_r2dgYuILKY
Occasional Contributor III

I have a dialog popup with a hyperlink. I want the popup to close when the link is clicked. I've tried "nboLink.on("click", closeDialog);" but the console says that this is not a function. Here is my code: 

Layer.on("click", function(evt){
            var name = evt.graphic.attributes.NAME;
            var nameNoDot = name.replace(/\./g,"");
            var nameDash = nameNoDot.replace(/_/g, "-");
            var nameLower = nameDash.toLowerCase();
           
            
          var nboLink = "<b>${NAME}</b><hr><a target='_blank' href='http://website/profiles/" + nameLower +
              "'><b>Profile</b></a>";
                   
          var popupContent = esriLang.substitute(evt.graphic.attributes,nboLink);
            
          dialog.setContent(popupContent);

          domStyle.set(dialog.domNode, "opacity", 0.70);
            
          dijitPopup.open({
            popup: dialog,
            x: evt.pageX,
            y: evt.pageY,
          });
     
          function closeDialog(){
               map.graphics.clear();
               dijitPopup.close(dialog);
               };
               
          
        });‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍
0 Kudos
13 Replies
deleted-user-1_r2dgYuILKY
Occasional Contributor III

I'm revisiting this thread with a similar question. Would it be possible to close a popup after clicking on a linked attachment in a feature layer? 

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Levi,

   I'm confused is that not what we are doing now?..

0 Kudos
deleted-user-1_r2dgYuILKY
Occasional Contributor III

The difference is this is a basic feature layer popup with attachment. No hyperlink with DOM ID. 

var popup = new Popup(popupOptions, domConstruct.create("div"));
               
               
            var popupTemplate = new PopupTemplate({
           title: "Storm: {name}",
     
            showAttachments:true
          });
0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Levi,

   It is possible. You would have to link to the popup show event and then use dojo query to find the attribute link class and assign a click event to that dom object that will do map.infoWindow.hide();

0 Kudos