Skip to content

Instantly share code, notes, and snippets.

@willbuilds
Last active August 29, 2015 14:20
Show Gist options
  • Save willbuilds/5d6fb9ee6ba4a55499b2 to your computer and use it in GitHub Desktop.
Save willbuilds/5d6fb9ee6ba4a55499b2 to your computer and use it in GitHub Desktop.
// General loadmasking for all ajax controls using jquery loadmask
// Prevents double requests and gives users better feedback ('Did i click that properly?'), especially on touch devices.
// On ajaxBefore (which equates to onclick in most cases) a mask will render over the target element
// On ajaxComplete the mask is destroyed.
// requires jquery.loadmask.js (@ https://code.google.com/p/jquery-loadmask/)
$(document).on('ajaxBefore', function(event, request) {
return $(event.target).mask('loading...');
}).on('ajaxComplete', function(event, request) {
return $(event.target).unmask();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment