Select to view content in your preferred language

Popup content with deferred object

3424
3
07-28-2015 10:06 PM
MichaelKefahuchi
Deactivated User

I am trying to display attribute infos and attachment in popup
window. It can be quite good handled by code selected as correct answer
here (https://community.esri.com/thread/159806).
  Basically you create two event handlers for “click” and
“query-attachment-infos-complete“ and in second one you set content of
infoTemplate.

The problem with this approach is somehow „cosmetical“, but I would
like to solve it. If you click two features that are close enough to
each other you get a popup with label like „1/2“ and arrow that is
supposed to switch popup conten to feature „2/2“. The problem is that on
feature 2/2 the content (attachement url, or thumbnail) is the same as
for feature 1/2 . It is probably because in handler for
“query-attachment-infos-complete“  you set infoTemplate.content for one
feature and that infoTemplate is used for second feature as well.

So I am wondering if this could not be better solved with similar approach as in the tutorial here:
https://developers.arcgis.com/javascript/jshelp/intro_formatinfowindow.html
(at the bottom of the page, after Deferred Object bullet).
In this approach you set content for infoWindow by function, let’s call
it getTextContent(graphic). And inside this function you can run method
featureLayer. queryAttachmentInfos(OBJECTID) which return value is
deferred object. So you can implement callback function and get
attachement url. I am just totally lame to get attachement url from that
callback function into return variable for getTextContent function. The
scratch version is like this:

function getTextContent(graphic)
{
  var deferred = editLayer.queryAttachmentInfos(
  graphic.attributes.OBJECTID,
  function (attachemntInfos)
  {
  var attachmentUrl = attachemntInfos[0].url;
  return attachmentUrl;
  });

  //I wish this would be attachmentUrl...
  return ???attachmentUrl

}

Any help,idea, comment would by very appreciated.

0 Kudos
3 Replies
MichaelKefahuchi
Deactivated User

More than one month without answer? Come one, at least tell me that it is bad approach and it won' work or something 🙂 ...

0 Kudos
JeffJacobson
Frequent Contributor

Can you put your code on JSFiddle or Plunker? If people can see your code running in such an environment it will be a lot more likely that someone will figure out the problem.

0 Kudos
MichaelKefahuchi
Deactivated User

Jeff, thank you for your suggestion. Here is fiddle https://jsfiddle.net/kefahuchi/esc88t43/1/

I basically used esri sample for this fiddle, the important part for me is "getInfoText" function, e.g. lines 36 -65. Thank you.

0 Kudos