Skip to content

Instantly share code, notes, and snippets.

@fabrinal
Created June 1, 2015 12:54
Show Gist options
  • Save fabrinal/59194a226c085719237a to your computer and use it in GitHub Desktop.
Save fabrinal/59194a226c085719237a to your computer and use it in GitHub Desktop.
Add ajax to delete single photo
$(document).ready ->
$('.delete_photo').each ->
$(this).click ->
if confirm("Are you sure to delete photo?")
photo_id = $(this).attr('data-value')
$(this).on "ajax:success",() ->
alert("Photo deleted successfully")
$("a[data-value="+photo_id+"]").remove()
$("#photo"+photo_id).remove()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment