Let's take a look at the description in the API about Ext. Message:
Note that theMessageBox is asynchronous. Unlike a regular JavaScriptalert
(Whichwill halt browser execution), showing a MessageBox will not cause the code tostop. For this reason, if you have code that shocould only runAfterSome user feedback from the MessageBox, you must use a callback function (seethefunction
Parameter for show for more details ).
Here, we should note that Ext's MessageBox is asynchronous, which is different from JS's alert. When JavaScript's alert is executed, the code will be suspended and the code will not continue to be executed, the MessageBox of Ext will continue to be executed. So sometimes we will see MessageBox will flash and pass. How can this problem be solved? It is actually very simple.
Let's take a look at the definition of alert in MessageBox:
Alert(Stringtitle
,String msg
,[Functionfn
],[Object scope
]): Ext. MessageBox
Note that the third parameter does not exist? Is a function. Let's look at the description of the function:
·Fn: Function
(Optional) Thecallback function invoked after the message box is closed
Is the callback function executed after the window is closed.
The solution is to put the subsequent execution actions in this function and continue execution after the window is closed.