diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/dom-event-handlers.js b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/dom-event-handlers.js index 65f58f2e84..cdeb952319 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/dom-event-handlers.js +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/dom-event-handlers.js @@ -1,4 +1,4 @@ -(function() { +(function($) { abp.dom.onNodeAdded(function (args) { args.$el.findWithSelf('[data-toggle="tooltip"]').tooltip({ @@ -8,6 +8,13 @@ args.$el.findWithSelf('[data-toggle="popover"]').popover({ container: 'body' }); + + var $forms = args.$el.findWithSelf('form'); + if ($forms.length) { + $forms.each(function() { + $.validator.unobtrusive.parse($(this)); + }); + } }); abp.dom.onNodeRemoved(function (args) { @@ -26,4 +33,4 @@ }); }); -})(); \ No newline at end of file +})(jQuery); \ No newline at end of file diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/modal-manager.js b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/modal-manager.js index 5d670db7f9..43d4bd10c3 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/modal-manager.js +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/bootstrap/modal-manager.js @@ -66,11 +66,8 @@ $.validator.defaults.ignore = ''; //TODO: Would be better if we can apply only f _$modal = _$modalContainer.find('.modal'); _$form = _$modalContainer.find('form'); if (_$form.length) { - $.validator.unobtrusive.parse(_$form); //TODO: We should do a more common system to initialize component on ajax-loaded DOM elements. validator.unobtrusive.parse is only one thing to do. if (_$form.attr('data-ajaxForm') !== 'false') { - //TODO: Create abpAjaxForm to not repeat that code! _$form.abpAjaxForm({ - dataType: 'json', success: function() { _publicApi.setResult.apply(_publicApi, arguments); _$modal.modal('hide'); diff --git a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js index fb1036a588..e767359bc6 100644 --- a/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js +++ b/src/Volo.Abp.AspNetCore.Mvc.UI.Theme.Shared/wwwroot/libs/abp/aspnetcore.mvc.ui.theme.shared/jquery-form/jquery-form-extensions.js @@ -9,14 +9,17 @@ var options = $.extend({}, $.fn.abpAjaxForm.defaults, userOptions); options.beforeSubmit = function (arr, $form) { - var retVal = userOptions.beforeSubmit && userOptions.beforeSubmit.apply(this, arguments); + if (userOptions.beforeSubmit && userOptions.beforeSubmit.apply(this, arguments) === false) { + return false; + } - if (retVal !== false) { - $form.find("button[type='submit']").buttonBusy(true); - //TODO: Disable other buttons..? + if (!$form.valid()) { + return false; } - return retVal; + $form.find("button[type='submit']").buttonBusy(true); + //TODO: Disable other buttons..? + return true; }; options.error = function (jqXhr) {