Why is there no content in popup after search?

778
2
Jump to solution
01-17-2018 11:37 AM
BrandonFlessner
Occasional Contributor

I've set up a feature layer with a popup and added it to my map. I'm also making the feature layer searchable via the search widget. When I search and select a result, the popup opens, and the title is fine, but the content is missing. Here's a demo:

https://codepen.io/anon/pen/dJgxVQ?editors=1000

When I search for district '2003' I get this (incorrect, no content):

Popup with no content

When I simply click on the feature, I get this (correct):

Popup with correct content

When poking around in the debugger, I see that when the popup has no content, popup.selectedFeature.layer is null. What's going on here? I simply want the same popup to show up if I click the feature or search. Thanks for any help you can provide!!

0 Kudos
1 Solution

Accepted Solutions
RobertScheitlin__GISP
MVP Emeritus

Brandon,

   You have to be careful as JS is a case sensitive language. You had:

      var congress = new FeatureLayer({
            url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServ...",
            popupTemplate: { // autocasts as new PopupTemplate()
              title: "Congressional District {DISTRICTID} </br>{NAME}, {PARTY}",
              content: "{Name} {Party}",
              overwriteActions: true
            }
          });

Which should have been:

      var congress = new FeatureLayer({
            url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServ...",
            popupTemplate: { // autocasts as new PopupTemplate()
              title: "Congressional District {DISTRICTID} </br>{NAME}, {PARTY}",
              content: "{NAME} {PARTY}",
              overwriteActions: true
            }
          });

Notice field names are upper case in the content property now.

View solution in original post

0 Kudos
2 Replies
RobertScheitlin__GISP
MVP Emeritus

Brandon,

   You have to be careful as JS is a case sensitive language. You had:

      var congress = new FeatureLayer({
            url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServ...",
            popupTemplate: { // autocasts as new PopupTemplate()
              title: "Congressional District {DISTRICTID} </br>{NAME}, {PARTY}",
              content: "{Name} {Party}",
              overwriteActions: true
            }
          });

Which should have been:

      var congress = new FeatureLayer({
            url: "https://services.arcgis.com/V6ZHFr6zdgNZuVG0/arcgis/rest/services/CongressionalDistricts/FeatureServ...",
            popupTemplate: { // autocasts as new PopupTemplate()
              title: "Congressional District {DISTRICTID} </br>{NAME}, {PARTY}",
              content: "{NAME} {PARTY}",
              overwriteActions: true
            }
          });

Notice field names are upper case in the content property now.

0 Kudos
BrandonFlessner
Occasional Contributor

Excellent! I knew it must be something silly. Thanks Robert

0 Kudos