Skip to content

Instantly share code, notes, and snippets.

@itzsaga
Created June 16, 2017 04:39
Show Gist options
  • Save itzsaga/002b6e3839d659322058a5d27f336cdb to your computer and use it in GitHub Desktop.
Save itzsaga/002b6e3839d659322058a5d27f336cdb to your computer and use it in GitHub Desktop.
$('.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