0

有两个弹出窗口。如果返回 true,则出现第二个而不是第一个showAlert(text)(请参阅下面的工作代码)。

如何修改它以在第二条消息确定后始终显示第一条消息的方式?

结果,它看起来像:

1. Please enter your email. 
2. If email is correct, then go to step 5.
3. Please, fix your email. Click OK.
4. Go to step 1.
5. Success. Finished.

我的工作代码如下。

Ext.Msg.prompt(
    'My Title', //The title bar text 
    'This is the first message', //The message box body text
    function (btn, text) {
       if (btn == 'ok') {
          if (showAlert(text)) {
              Ext.Msg.alert('', 'Please, fix it');//to show first message upon OK button
           } else {
                //do something useful
           }
       }
    },
    //some more params
);
4

1 回答 1

1

Make your call a function, and call that function as the callback if the email is not valid:

function showPrompt() {
    Ext.Msg.prompt(
        'My Title', //The title bar text 
        'This is the first message', //The message box body text
        function (btn, text) {
            if (btn == 'ok') {
                if (showAlert(text)) {
                    Ext.Msg.alert('', 'Please, fix it', showPrompt);
                } else {
                    //do something useful
                }
            }
        },
        //some more params
    );
}
于 2013-07-26T14:41:20.467 回答