From b52bab7e55d8a0386abcc876064478024e42295f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 12 Oct 2020 15:25:55 +0300 Subject: [PATCH] Finish the modals document --- docs/en/UI/AspNetCore/Modals.md | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/docs/en/UI/AspNetCore/Modals.md b/docs/en/UI/AspNetCore/Modals.md index 3a60a4bd61..bcbe342973 100644 --- a/docs/en/UI/AspNetCore/Modals.md +++ b/docs/en/UI/AspNetCore/Modals.md @@ -297,9 +297,19 @@ The resulting modal will be like that: #### Saving the Modal -When you click to the `Save` button, the form is posted to the server. If server returns a success response, the modal is closed. Otherwise, it shows the error message returned from the server. +When you click to the `Save` button, the form is posted to the server. If the server returns a **success response**, then the `onResult` event is triggered with some arguments including the server response and the modal is automatically closed. -> You can register to the events to be informed when form is saved or modal is closed. See the *Modal Manager Reference* section below. +An example callback that logs the arguments passed to the `onResult` method: + +````js +productCreateModal.onResult(function(){ + console.log(arguments); +}); +```` + +If the server returns a failed response, it shows the error message returned from the server and keeps the modal open. + +> See the *Modal Manager Reference* section below for other modal events. #### Canceling the Modal @@ -307,6 +317,14 @@ If you click to the Cancel button with some changes made but not saved, you get ![modal-manager-cancel-warning](../../images/modal-manager-cancel-warning.png) +If you don't want such a check & message, you can add `data-check-form-on-close="false"` attribute to your `form` element. Example: + +````html +
+```` + ### Form Validation `ModalManager` automatically triggers the form validation when you click to the `Save` button or hit the `Enter` key on the form: @@ -315,7 +333,7 @@ If you click to the Cancel button with some changes made but not saved, you get See the [Forms & Validation document](../Forms-Validation.md) to learn more about the validation. -## Modals with Script +## Modals with Script Files You may need to perform some logic for your modal. To do that, create a JavaScript file like below: