Last active
December 25, 2015 03:49
-
-
Save jakeboxer/6913132 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Prevent double-clicking on things, with fix for button value | |
| $(document).on 'click', '[data-disable-with]', -> | |
| $element = $(this) | |
| this.disabled = true | |
| if disableWith = $element.attr('data-disable-with') | |
| $element.html(disableWith) | |
| # This is a hilarious and gross fix to get the clicked button's name and | |
| # value into the manually submitted form below, as it would be with a normal | |
| # browser submit. | |
| $("<input type='hidden' name='#{$element.attr('name')}' value='#{$element.val()}'>").prependTo($element) | |
| # Disabling the button prevents the form from submitting, so we have to force | |
| # the submit here. | |
| $element.closest('form').submit() | |
| false |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Prevent double-clicking on things | |
| $(document).on 'click', '[data-disable-with]', -> | |
| $element = $(this) | |
| this.disabled = true | |
| if disableWith = $element.attr('data-disable-with') | |
| $element.html(disableWith) | |
| # 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