Browse Source

Update documentation

pull/23915/head
enisn 11 months ago
parent
commit
603fa83099
No known key found for this signature in database GPG Key ID: A052619F04155D1C
  1. 61
      docs/en/framework/ui/mvc-razor-pages/javascript-api/message.md
  2. BIN
      docs/en/images/js-message-prompt.png

61
docs/en/framework/ui/mvc-razor-pages/javascript-api/message.md

@ -88,6 +88,58 @@ abp.message.confirm(
});
````
## Prompt Message
`abp.message.prompt(...)` can be used to get a text (or other input) from the user.
Simple usage:
```js
abp.message.prompt('Please enter a name:', (value)=> console.log('Entered name:', value));
```
**Example (then):**
````js
let options = { title: "Name Change" ,icon: "info", inputValue: "John Doe"};
abp.message.prompt('Enter a new name to change your name', options)
.then(function(value){
if (value) {
console.log('Entered name:', value);
}
});
````
**Example (await):**
````js
(async function(){
let options = { title: "Email Registration" ,icon: "info", input: "email"};
const email = await abp.message.prompt('Enter your email:', options);
if (email) {
console.log('Entered email:', email);
}
})();
````
![js-message-prompt](../../../../images/js-message-prompt.png)
### The Return Value
The return value of the `abp.message.prompt(...)` function is a promise that resolves to the entered value (`string`) or `null` if the dialog is canceled/dismissed.
### Parameters
`abp.message.prompt(...)` function has the following parameters:
* `message`: A message (`string`) to show to the user.
* `titleOrOptionsOrCallback` (optional):
* a `string` title, or
* an `object` containing SweetAlert options (e.g., `input`, `inputAttributes`, `inputPlaceholder`), or
* a `function` callback that receives the resulting value (or `null`).
* `callback` (optional): If you've passed a title as the second parameter, you can pass your callback function as the 3rd parameter.
Passing a callback function is an alternative to using the returned promise.
## SweetAlert Configuration
The Message API is implemented using the [SweetAlert](https://sweetalert.js.org/) library by default. If you want to change its configuration, you can set the options in the `abp.libs.sweetAlert.config` object. The default configuration object is shown below:
@ -126,3 +178,12 @@ abp.libs.sweetAlert.config.warn.icon = 'error';
See the [SweetAlert document](https://sweetalert.js.org/) for all the configuration options.
There is also a `prompt` preset you can customize via `abp.libs.sweetAlert.config.prompt`:
````js
abp.libs.sweetAlert.config.prompt = {
icon: 'question',
input: 'text'
};
````

BIN
docs/en/images/js-message-prompt.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

Loading…
Cancel
Save