Skip to content

Instantly share code, notes, and snippets.

@jakeboxer
Last active December 20, 2015 06:09
Show Gist options
  • Select an option

  • Save jakeboxer/6083640 to your computer and use it in GitHub Desktop.

Select an option

Save jakeboxer/6083640 to your computer and use it in GitHub Desktop.
# Prevent double-clicking on things
$(document).on 'click', '.js-disable-on-click', ->
$element = $(this)
$element.attr('disabled', 'disabled')
$element.html($element.data('disabled-text'))
# Disabling the button prevents the form from submitting, so we have to force
# the submit here.
$element.closest('form').submit()
false
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment