Browse Source

Added buttonBusy extra options to abpAjaxForm (disableSubmitButtonBusy,disableOtherButtonsBusy, $excludedBusyButtons)

pull/279/head
Alper Ebicoglu 8 years ago
parent
commit
87d08d5f83
  1. 23
      src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js

23
src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js

@ -5,7 +5,13 @@
$.fn.abpAjaxForm = function (userOptions) {
var $form = $(this);
userOptions = userOptions || {};
userOptions = $.extend({
formSubmitting: {
disableSubmitButtonBusy: false,
disableOtherButtonsBusy: false,
$excludedBusyButtons: {} /*Prevents busy or disabled effect on these buttons. Must be jQuery instances*/
}
}, userOptions || {});
var options = $.extend({}, $.fn.abpAjaxForm.defaults, userOptions);
@ -18,8 +24,19 @@
return false;
}
$form.find("button[type='submit']").buttonBusy(true);
//TODO: Disable other buttons..?
if (!userOptions.formSubmitting.disableSubmitButtonBusy) {
var submitButtons = $form.find("button[type=submit]").not(userOptions.formSubmitting.$excludedBusyButtons);
if (submitButtons.length === 1) {
submitButtons.buttonBusy(true);
} else if (submitButtons.length > 1) {
$(document.activeElement).buttonBusy(true);
}
}
if (!userOptions.formSubmitting.disableOtherButtonsBusy) {
var otherButtons = $form.find("button[type!=submit]").not(userOptions.formSubmitting.$excludedBusyButtons);
otherButtons.prop('disabled', true);
}
return true;
};

Loading…
Cancel
Save