Last active
July 21, 2016 21:57
-
-
Save nallenanderson/4dd5090f9cd2edc49d6ee93a5eab2271 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Chain this onto the end of the AJAX request. | |
.then( () => { | |
// Create an array of <div>s and then map over each element to create a div with image and title. | |
const showImages = ` | |
${jsonData.map( card => { | |
return ` | |
<div class="col-md-6"> | |
<div class="card"> | |
<img src=${card.covers[0]} class="img-responsive" /> | |
<div class="card-title"> | |
<h4>${card.title}</h4> | |
</div> | |
</div> | |
</div> | |
` | |
} | |
) | |
// Remove any '' from the map array. | |
.join('')} | |
`; | |
const imagesDiv = document.querySelector('#images'); | |
imagesDiv.innerHTML = showImages; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment