2013-07-26 32 views
0

有兩個彈出窗口。如果showAlert(text)返回true,則第二個出現而不是第一個(請參閱下面的工作代碼)。Sencha Touch 2:遞歸消息框

如何修改它的方式來顯示第一條消息的所有時間回到第二條消息的確定?

至於結果,它看起來像:

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

讓你調用一個函數,並調用它的回調,如果電子郵件地址無效:

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