Link in popup window

808
1
06-19-2014 09:36 AM
VernWolfley
New Contributor III
I am trying to customize the popup window with a link at the bottom.  I have used this example https://developers.arcgis.com/javascript/jssamples/gp_popuplink.html to successfully add a link, but the link appears for each layer that is clicked.  I would like to remove the link when it is not needed for a specific layer.  Here is the code I have been using.  Any suggestions are welcome.  Thanks

//create a link in the popup window.
        var link = dc.create("a", {
            "class": "action",
            "id": "infoLink",
            "innerHTML": "Assessor Info", //text that appears in the popup for the link
            "href": "javascript: void(0);"
        }, query(".actionList", map.infoWindow.domNode)[0]);

        on(link, "click", function() {
            var feature = map.infoWindow.getSelectedFeature();
            // console.log(feature.attributes);
            var url = window.location;
            var link = "";
            if (feature.attributes.COUNTY_FIPS === "13") {
                link = appConfig.MaricopaAssessor + feature.attributes.PARCEL;
                window.open(link);
            }
            if (feature.attributes.COUNTY_FIPS === "25") {
                link = appConfig.YavapaiAssessor + feature.attributes.PARCEL;
                window.open(link);
            }
            else {
                // *** do nothing ***
            }

        });



[ATTACH=CONFIG]34750[/ATTACH]
0 Kudos
1 Reply
VivekPrasad
Occasional Contributor
Hi,

How about attaching a "Show" event to popup object and in the event handler, identify the current feature by using the properties, "features" and "selectedIndex" and then identify if the link can be shown for this feature either by attributes of the feature or by calling "getLayer" on feature(Graphic) object then identify using the layer object.

Showing and hiding can be done using esri/domUtils::show/hide methods.

Hope it helps!

Thanks & Regards,
Vara Prasad.
0 Kudos