1
0
mirror of https://github.com/e107inc/e107.git synced 2025-08-04 21:57:51 +02:00

Display loading button on form submit only when submit is successful. (no validation issues)

This commit is contained in:
Cameron
2016-04-11 17:58:22 -07:00
parent 9629bd4510
commit b762c10ecc

View File

@@ -747,20 +747,29 @@ $(document).ready(function()
{ {
var caption = $(this).text(); var caption = $(this).text();
var type = $(this).attr('data-loading-icon'); var type = $(this).attr('data-loading-icon');
var formid = $(this).closest('form').attr('id');
var but = $(this);
if(type === undefined) if(type === undefined || (formid === undefined))
{ {
return true; return true;
} }
$('#'+formid).submit(function(){ // only animate on successful submission.
caption = "<i class='fa fa-spin " + type + " fa-fw'></i><span>" + caption + "</span>"; caption = "<i class='fa fa-spin " + type + " fa-fw'></i><span>" + caption + "</span>";
$(this).html(caption); $(but).html(caption);
if($(this).attr('data-disable') == 'true') if( $(but).attr('data-disable') == 'true')
{ {
$(this).addClass('disabled');
$(but).addClass('disabled');
} }
});
return true; return true;
} }
); );