Skip to content

Instantly share code, notes, and snippets.

@twetzel
Forked from prasofty/gist:2487410
Last active August 28, 2017 21:39
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 twetzel/bc60165661975b95c4964c803f84ecec to your computer and use it in GitHub Desktop.
Save twetzel/bc60165661975b95c4964c803f84ecec to your computer and use it in GitHub Desktop.
Disable remote links after click in rails 3 +
$('a[data-remote=true]').on('ajax:before', function () {
if ($(this).hasClass('ajax-loading')) {
return false;
} else {
$(this).addClass('ajax-loading', true);
}
}).on('ajax:complete', function () {
$(this).removeClass('ajax-loading');
});
$('a[data-remote=true]').on('ajax:before', ->
if $(this).hasClass('ajax-loading')
return false
else
$(this).addClass 'ajax-loading'
).on 'ajax:complete', ->
$(this).removeClass 'ajax-loading'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment