Created
June 16, 2017 04:39
-
-
Save itzsaga/002b6e3839d659322058a5d27f336cdb 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
$('.js-next').on('click', function() { | |
let nextIndex = itemsValues.indexOf(parseInt($('.js-next').attr('data-id'))) + 1 | |
$.getJSON('/items/' + itemsValues[nextIndex], function(data) { | |
$('#name').html(data['name']) | |
$('#rating').html(data['rating']) | |
$('#notes').html(data['notes']) | |
if (nextIndex === itemsValues.length) | |
$('.js-next').attr('data-id', itemsValues[0]) | |
else | |
$('.js-next').attr('data-id', data['id']) | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment