zoukankan      html  css  js  c++  java
  • Ext.Msg.alert要注意的问题

    我们先看看API中关于Ext.Message的中的描述:

    Note that theMessageBox is asynchronous. Unlike a regular JavaScript alert (whichwill halt browser execution), showing a MessageBox will not cause the code tostop. For this reason, if you have code that should only run aftersome user feedback from the MessageBox, you must use a callback function (seethe function parameter for show for more details).

     

    这里要我们注意ExtMessageBox是异步,和JSalert是不同,JSalert执行的时候会挂起代码,不继续执行,而ExtMessageBox是会继续执行的。所以有时候我们会看到MessageBox会闪一下就过去了。如何解决这个问题呢?其实很简单。

    我们看看MessageBoxalert的定义:

    alertStringtitle,String msg, [Functionfn], [Object scope] ) : Ext.MessageBox

     

    注意第三个参数没有?是一个函数。我们看看函数的说明:

     

    ·  fn : Function

    (optional) Thecallback function invoked after the message box is closed

     

    是窗口关闭后执行的回调函数。

    呵呵,解决办法出来了,就是将后续的执行动作放到这个函数里,等窗口关闭后继续执行。
  • 相关阅读:
    Linux基础之计算机硬件
    python中 __cmp__
    python中 __str__和__repr__
    python的构造函数传入任意数量的参数
    python中的偏函数
    javascript正则表达式
    js实现复选框的全选、全部选和反选
    js中的函数对象
    js中的作用域
    js中的arguments
  • 原文地址:https://www.cnblogs.com/hainange/p/6334355.html
Copyright © 2011-2022 走看看