An exercise to create a very simple gallery made with jQuery and AJAX.
train the loading of data with AJAX, jQuery event handlers and CSS positioning.
-
create a GitHub repository
- got to your GitHub profile
- click the "Repositories"
- in the field "Repository name" enter "simple-gallery" (exactly)
- pick the "MIT" license
- click the "Dowload or clone" button
- make sure you are using the "SSH" URL (should start with "git@github"
- open a terminal
- enter
git clone <the SSH URL of your repository>
-
basics (see simple-slider-step-1.jpg)
- find (at least) 5 images licensed under creative common (https://unsplash.com/)
- create a file
data.json
consisting of an array of object with the keysauthor
src
link
title
- load the
data.json
file using$.getJSON()
- create a "pager" at the bottom of the page, when one of the pager item is clicked
- it changes the information (image, author name, author link and title) accordingly
- the clicked item is set to "active" (visually different from other pager items
Hint: use
removeClass
andaddClass
- when you load - or reload - the page, the first image must be displayed it with the right author, title and so)
Hint: use
.trigger()
- create a "Next" and "Back" button which when clicked act like clicking on either the next or the previous pager item