Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

Override error dialog on service error in SPA. #1030


User avatar
0
eggersa created

The default behavior of a form within a ASP.NET Zero template is to disable the submit button until the form is valid. Since I have a rather large form with multiple tabs I enable the button always as its difficult for the user to figure out why the button might be disabled. Instead, I handle the error event of the service proxy and if there are any validation errors I explicitly highlight the tabs with invalid form data.

vm.save = function () {
                vm.saving = true;
                customerService.createOrUpdateCustomer(vm.customer).success(function () {
                    $uibModalInstance.close();
                }).error(function (error) {
                    if (error.validationErrors && error.validationErrors.length > 0) {
                        // hightlight tabs with invalid form controls...
                    }
                }).finally(function () {
                    vm.saving = false;
                });
            };

Unfortunately I would like to disable the default behavior of a service error in this case. By default, the templates behavior is to show a SweetAlert popup with the error message. How can I override this behavior for this special case?


No answer yet!