title: jquery ajaxform global functions
body: <p>We are using the <a href="http://jquery.malsup.com/form/#getting-started" rel="nofollow">jQuery form plugin</a> on our site. We need to be able to show a loading gif when a submit occurs on all forms. So far I have been able to get this done like the following</p>
  
  <pre><code>    $("#uploadAssetImageForm").ajaxForm({
          dataType: 'json',
          beforeSubmit: function () {Cvrs.SetLoading(true, '#uploadAssetImageForm')},
          success: function(asset) {
              Cvrs.SetLoading(false, '#uploadAssetImageForm');
          $("#uploadAssetImageDiv").dialog("close");
              $(":input", "#uploadAssetImageDiv").not(':button, :submit, :reset').val('').removeAttr('checked').removeAttr('selected');
              ReplaceAsset(asset);
  
          }
      });
  </code></pre>
  
  <p>In particular the parts I'm talking about are the beforeSubmit function and the call again to set it to false on success.</p>
  
  <p>Set loading just shows a loading gif and disabled form buttons</p>
  
  <pre><code>function(isLoading, form) {
  
  isLoading ? $(form + ' input[type="submit"]').attr("disabled", true) :
      $(form + ' input[type="submit"]').removeAttr("disabled");
  
  
  isLoading ? $(form + ' .loading-animation').show() :
      $(form + ' .loading-animation').hide();
  </code></pre>
  
  <p>Is there any way I can get any call to ajaxform to run that code on the beforeSubmit and success along with any other code that might be there as well (running the loading stuff first though) or do I have to go through each case and add this in?</p>
  
  <p>I understand I'll have to put the loading reference in each form but this makes sense as its possible that different forms could need the loading gif in different spots</p>