Skip to content

Instantly share code, notes, and snippets.

@dgmike
Forked from ozgun/ajax_loading.js
Created October 1, 2012 12:52
Show Gist options
  • Save dgmike/3811627 to your computer and use it in GitHub Desktop.
Save dgmike/3811627 to your computer and use it in GitHub Desktop.
ajax_loading.js
$(document).ready(function() {
$(".ajax_request").bind('ajax:before', function(evt, status, data, xhr) {
showAjaxLoading();
});
$(".ajax_request").bind('ajax:complete', function(evt, status, data, xhr) {
hideAjaxLoading();
});
$(".disable_page").bind('ajax:before', function(evt, status, data, xhr) {
disable_page();
});
$(".disable_page").bind('ajax:complete', function(evt, status, data, xhr) {
enable_page();
});
$(".ajax_form").bind('ajax:before', function(evt, status, data, xhr) {
$(this).find('input[type=submit]').attr('disabled', 'disabled')
});
$(".ajax_form").bind('ajax:complete', function(evt, status, data, xhr) {
$(this).find('input[type=submit]').removeAttr('disabled')
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment