0

I might have went about this the wrong way, though I thought it may be a good idea to ask before starting over again. I have a picture column in cartodb which has multiple picture ids separated by commas. So I created a script that would take those values and parse the ids out into an a href tag. My question: Is there a way to grab the json value inside infowindow template {{ photo_column}} and run the value to my script?

var str = '7BC414B0-B38E-4A70-9464-65CCAEC39C8E,327CF268-6742-4E20-9C92-41E9945FCCBD';
var myarray = str.split(',');
var url = "https://web.fulcrumapp.com/api/v2/photos/";
var token = ".jpg?token=3231c4d7309903b454ac10da556778cdf775b72192a96b3";
    for (var i = 0; i < myarray.length; i++) {
       document.write("<li><a href=\"" + url + "" + myarray[i] + "" + token + "\" target=\"_blank\"><img src=\"" + url + "" + myarray[i] + "\"></a></li>");
1
  • 1
    not exactly sure what you're trying to do here...maybe include more code, a link to your web page, or a link to a jsfiddle example...?
    – sfletche
    May 12, 2014 at 3:58

1 Answer 1

1

You can call a javascript method from the infowindow template, check this example:

http://bl.ocks.org/javisantana/6029822

2
  • Thank you Javisantana I was able to access the json photo column from the cartodb table and parse out the photos since there are many photos to one feature. however I am still having a difficult time formatting my function in order to get the photos to show up in the infowindow. jsfiddle.net/CrazySpatial/9Hwcg May 13, 2014 at 14:24
  • could you provide a full working example? May 20, 2014 at 9:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.