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);
};
});
Solved! Go to Solution.
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?
Levi,
I'm confused is that not what we are doing now?..
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
});
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();