ExtJS Ext. MessageBox. alert () dialog box details

Source: Internet
Author: User

Copy codeThe Code is as follows:
Ext. onReady (function (){
Ext. Msg. alert ('hprompt ', 'comma-separated parameter list'); // This method is very common
});

:

Copy codeThe Code is as follows:
Ext. onReady (function (){
// Define JSON (configuration object)
Var config = {
Title: 'hup ',
Msg: 'json configuration method, simple'
}
Ext. Msg. show (config );
});

:

The above is just a simple example. Now you can see the beautiful interface! Next let's get to knowExt. MessageBox
Ext. messageBox is a tool class inherited from the Obiect object. It is used to generate information prompt dialog boxes of various styles, Ext. msg is the alias of this class. Use Ext. messageBox and Ext. msg works the same, while the latter provides a simpler method. Before the introduction, let's take a look at Ext. the difference between the information prompt box provided by MessageBox and the original information prompt box provided by JavaScript is mainly manifested in three aspects, they are "implementation method", "Display Information Format", and "impact on program running", which are described in detail in the following three aspects.
1. Implementation Method:
The prompt dialog box provided by standard JavaScript is a real pop-up window. The message prompt dialog box provided by Ext. MessageBox is not a real pop-up window. It is only a layer (div) displayed on the current page, so you cannot use the window to catch the software.
2. Display Information Format:
The information displayed in the prompt dialog box provided by standard JavaScript is not HTML text, but plain text.
You cannot use the formatting method in HEML for formatting. You can only use spaces, carriage returns, and various metric characters to build the display format.
The text displayed in the message prompt dialog box provided by Ext. MessageBox not only supports plain text display, but also supports HTML text format and HTML formatting, with richer effects. The following is a simple example.
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Alert ('only plain text'); // HTML strings are not supported here
</Script>

:

Copy codeThe Code is as follows:
// Html text supported
Ext. onReady (function (){
Ext. Msg. alert ('<font size = 4> prompt </font>', '<font color = red> html text supported </font> ');
});

:

Copy codeThe Code is as follows:
<Script type = "text/javascript">
Ext. onReady (function (){
Alert ('I will stop executing the program ');
Ext. Msg. alert ('hprompt ',' I won't stop executing the program ');
});
</Script>

:

Copy codeThe Code is as follows:
<Script type = "text/javascript">
Ext. onReady (function (){
Ext. Msg. alert ('hprompt ',' I won't stop executing the program ');
Alert ('I will stop executing the program ');
});
</Script>

:

It's easy to see the results! The following describes how to call back a function. a read-only prompt box is used to replace the JavaScript standard alert () method with a confirmation button. if it provides a callback function, the function will be called after the button is clicked (including the push button in the upper right corner). the id of the clicked button will be passed to the callback function as a unique parameter.
Call format:
Alert (String title, String msg, [function fn], [Object scope]);
// Parameter description
Title: The title of the prompt box.
Msg: information displayed
[Function fn]: (optional) callback function
[Object scopt]: (optional) scope of the callback function
Return Value:
Ext. MessageBox
Example:
Copy codeThe Code is as follows:
<Script type = "text/javascript">
Ext. onReady (function (){
Ext. MessageBox. alert ('hprompt ', 'click OK, callback );
Function callBack (id ){
Alert ('click the button id: '+ id );
}
});
</Script>

:
Click OK

Click x

 

Tip: the alert of ExtJS is asynchronously executed without blocking. Therefore, you must place the code that is executed after confirmation in the callback function, otherwise, subsequent code execution may cause unnecessary errors after the user confirms, which requires our attention.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.