Sencha Touch 2:递归消息框

时间:2013-07-26 14:09:22

标签: javascript recursion popup sencha-touch-2 message

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

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

结果,它看起来像:

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
);

1 个答案:

答案 0 :(得分:1)

将您的通话作为一项功能,如果电子邮件无效,则将该功能称为回叫:

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
    );
}