Skip to content

Instantly share code, notes, and snippets.

@chug2k
Last active August 29, 2015 13:55
Show Gist options
  • Select an option

  • Save chug2k/8778901 to your computer and use it in GitHub Desktop.

Select an option

Save chug2k/8778901 to your computer and use it in GitHub Desktop.
$('.like-button').on('click', function(evt) {
evt.preventDefault();
var $btn = $(evt.currentTarget);
$.post('/likes/ ' + $btn.data('bookmark-id'))
.success(function(response) {
$btn.removeClass('like-button').addClass('unlike-button');
$btn.text('unlike');
// Show flash message, instead probably.
alert('You just liked something successfully');
}).fail(function(response) {
alert('SOMETHING WENT WRONG :(');
});
});
$('.unlike-button').on('click', function(evt) {
// ... you get the idea, hopefully.
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment