Select to view content in your preferred language

Don't want a title on infoTemplate, but still want X to close

6919
38
Jump to solution
10-21-2015 08:31 AM
TracySchloss
Honored Contributor

I would rather not have a title to my infoTemplate window.  I don't need to repeat the name of the location again, when I want it as part of the content and if you title it something like "Location Information", all I can think is "Duh, of course it's the location information, I just clicked it!".  If you don't set any title, you still get one, but it's set to ObjectID, which not many people care to see.

Trying infoTemplate.setTitle("") you still get objectid as your title.  If you set it to infoTemplate.setTitle(" "), with a blank space, then you can have no title. However now the whole header is left off, and I still want it to have an X to close, along with any next, previous arrow that might come with having multiple features selected.

I looked at the infoWindowLite, but I don't like the big red X as a substitute for an anchor pointing to an element.

I'm creating a plain infoTemplate, then populating it with a function.  I've tried map with a popup parameter and without one and that makes no difference.

var infoTemplate = new InfoTemplate();

 var   featureLayer =  new FeatureLayer(pathName+"/arcgis/rest/services/MDA/sampleGeocodeEdit/FeatureServer/0",{
        id:"featureLayer",
        outFields:['*'],
        infoTemplate:infoTemplate
     });
     featureLayer.renderer = renderer;
     featureLayer.setSelectionSymbol(highlightMarkerSymbol);
     
 //edit the selected feature    
     var selectQuery = new Query();
     
     on(featureLayer, "click", function(evt){
       formatString = "";
       var  objectId = evt.graphic.attributes[featureLayer.objectIdField];
        selectQuery.objectIds = [objectId];
        featureLayer.selectFeatures(selectQuery);      
     });
    on(featureLayer, "error", function (err){
      console.log("error with featureLayer; " + err.message);
    });
    
    on(featureLayer, 'selection-complete', setWindowContent);
   
function setWindowContent(results){
   map.infoWindow.resize(240, 100);
     var imageString = "<table><tr>";
     var imageStyle = "alt='site image' style='height=:40px width:40px float:left'";
     var deferred = new Deferred;
      var graphic = results.features[0];
      var  objectId = graphic.attributes[featureLayer.objectIdField]; 
         
      featureLayer.queryAttachmentInfos(objectId).then(function(response){
          var imgSrc;
          if (response.length === 0) {
              deferred.resolve("no attachments");
          }
          else {
              imgSrc = response[0].url;
              imageString += "<td><img src='" + imgSrc + "' " + imageStyle + "></td>";
              formatString += imageString;
              domConstruct.empty("attachPreviewDiv");
              domConstruct.create("img", {
                  src: imgSrc
              }, "attachPreviewDiv");
          }
          formatString += "<td><b>" + graphic.attributes.Facility + "</b><br/>" + graphic.attributes.Address + "<br/>" +
          graphic.attributes.City +  ", " + graphic.attributes.State +
          "<td></tr></table>";
          
          infoTemplate.setContent(formatString);
          infoTemplate.setTitle(" ");
      });
   map.enableMapNavigation();
 }    
0 Kudos
38 Replies
TracySchloss
Honored Contributor

Thank you!  Once again, I'm getting some funky behavior in IE.  The first time it positioned the infoWindow in the far upper left.

infoWindow_IEpng.png

Then I clicked this one and it worked:

infoWindowIE2.png

Then I clicked the red pin just about it - and it drew this same infoWindow again in the same place as 'somewhere around here'.

After that, it started working correctly.

Looking at this in Chrome, you can see that the first feature you clicked sort of flashes an infoWindow in the upper right before it places it correctly.

0 Kudos
KellyHutchins
Esri Notable Contributor

Which version of IE? Here's a link to a revised version of your code above that has problems on IE. I modified it to remove the feature selection - wasn't needed because the feature layer click event gives us the graphic. Tested on IE10 and 11 and worked for me.

JS Bin - Collaborative JavaScript Debugging

edited to provide correct link to bin.

0 Kudos
TracySchloss
Honored Contributor

I have IE 11, looks like 11.0.9600,18015CO.

This still isn't working for me correctly.  I'm having to click twice for each before I get the tag.

0 Kudos
SteveCole
Honored Contributor

I'm seeing the same two click behavior with my IE-11 install: 11.0.9600.180059 (Update Versions 11.0.24).

0 Kudos
KellyHutchins
Esri Notable Contributor

I can repro the issue in IE with two clicks. Not quite sure what is going on but I'm looking into it. The odd thing is that in a similar app the two click behavior in IE doesn't occur.

Report Graffiti

0 Kudos
KellyHutchins
Esri Notable Contributor

Ok this one works for me in IE11. Can you test and let me know if it works for you?

JS Bin - Collaborative JavaScript Debugging

Feels like there's an IE bug here so if you have access to support can you submit an issue? 

0 Kudos
KellyHutchins
Esri Notable Contributor

Ignore my last post. Here's another option that works in IE and I think its a cleaner solution than the other one.

JS Bin - Collaborative JavaScript Debugging

0 Kudos
TracySchloss
Honored Contributor

Both solutions worked for me.  I'd be happy to report a bug, unless you've decided there really isn't one?  I'm not sure what I'd be reporting, except the previous iterations before this all failed, when they probably should have worked in IE.

0 Kudos
KellyHutchins
Esri Notable Contributor

I think its just some odd ie behavior due to the async request for attachments. After coming up with solution 2 I tend to think its not a bug.

0 Kudos