Skip to content

Instantly share code, notes, and snippets.

@luckyruby
Created January 12, 2017 21:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save luckyruby/005e8c96f0a4030e3f7bffdc24b2114b to your computer and use it in GitHub Desktop.
Save luckyruby/005e8c96f0a4030e3f7bffdc24b2114b to your computer and use it in GitHub Desktop.
$(document).on "change", ".paid_checkbox", ->
url = $(this).data('paid-url')
if $(this).is(":checked")
box = confirm "Are you sure you want to mark as paid?"
if box is true
$.get url, { paid: "1"}
else
$(this).prop "checked", false
else
box = confirm "Are you sure you want to mark as unpaid?"
if box is true
$.get url, { paid: "0"}
else
$(this).prop "checked", true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment