From 8141c06fa5b0ccd8f44b7cb239d6fe82ecce03a1 Mon Sep 17 00:00:00 2001 From: benni Date: Mon, 20 Jun 2011 00:48:05 +0200 Subject: [PATCH] Some ajax loading callback. --- public/javascripts/application.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public/javascripts/application.js b/public/javascripts/application.js index ced3fbc6..b1c8e9e0 100644 --- a/public/javascripts/application.js +++ b/public/javascripts/application.js @@ -66,6 +66,20 @@ $(function() { $.getScript($(this).attr('href')); return false; }); + + // Show and hide loader on ajax callbacks + $('*[data-remote]').bind('ajax:beforeSend', function() { + $('#loader').show(); + }); + + $('*[data-remote]').bind('ajax:complete', function() { + $('#loader').hide(); + }); + + // Disable submit button on ajax forms + $('form[data-remote]').bind('ajax:beforeSend', function() { + $(this).children('input[type="submit"]').attr('disabled', 'disabled'); + }); });