Skip to content

Instantly share code, notes, and snippets.

@dannyduc
Created September 25, 2013 04:32
Show Gist options
  • Save dannyduc/6695183 to your computer and use it in GitHub Desktop.
Save dannyduc/6695183 to your computer and use it in GitHub Desktop.
Sample jQuery code to fetch and render list of sample iReports
$(function () {
$.getJSON('https://apps.ingenuity.com/irs/data/public/samplereports?jsoncallback=?')
.done(function (samples) {
var ul = $('<ul>');
$.each(samples, function (index, sample) {
$("<li>")
.append(
$("<a>")
.attr('href', 'https://apps.ingenuity.com/ireport/data/report?reportid=' + sample.reportId)
.attr('target', '_blank')
.append($('<img>', {
'class': 'icon',
'src': 'http://www.ingenuity.com/wp-content/themes/ingenuitytheme/images/icons/link.png',
'width': '16',
'height': '16',
'alt': 'download icon'
}).before(sample.title + "\n"))
).appendTo(ul);
});
$('#trainingbox').find('> ul').replaceWith(ul);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment