Search code examples
arcgis-js-api

ESRI JS API is stripping hrefs


ESRI's JS API seems to be stripping out the hrefs of URLs.

Here I set up a static link. Then I attempt to put it in the description. The link text and target="blank" are rendered but the link's href (test/) is blank!

    {% for project in projects %}

    var link = "<a target='blank' href='test'>Legal Description</a>";
    console.log(link) // This prints as expected with href intact.

    var attributes = {
        Name: "{{project.description}}",
        Description: link // strips out the href?!?!?!?!
    }

enter image description here

It SHOULD be localhost:8000/projects/test but there is no test href.


Solution

  • The arcgis-js-api sanitizes html content in popups for security reasons. I'm not sure how you're defining your popups or using the attributes variable, but you'll want to create a PopupTemplate, and its its content property to do what you want. You can do it like the linked article recommends, or you can use a CustomContent instance for the popupTemplate content property.