2011-11-08 28 views
2

我在我的應用程序的註銷選項中放了一個確認框。代碼相同如下:Sencha touch中的確認框中的是/否按鈕

var abc = Ext.Msg.confirm('Confirm logout', 'Are you sure you want to logout?', function(e) 
{ 
    if(e == 'yes') 
    { 
     // logout code 
    } 
} 
); 

確認框的按鈕在yes按鈕之前是可見的。

如何在No Button之前顯示Yes按鈕?

任何幫助表示讚賞。

回答

4

按照煎茶觸摸的源代碼(http://docs.sencha.com/touch/1-1/source/MessageBox.html#Ext-MessageBox-method-confirm) YESNO被定義爲「不,是」:

(function(){ 
    var B = Ext.MessageBox; 

    Ext.apply(B, { 
     OK  : {text : 'OK',  itemId : 'ok', ui : 'action' }, 
     CANCEL : {text : 'Cancel', itemId : 'cancel'}, 
     YES : {text : 'Yes', itemId : 'yes', ui : 'action' }, 
     NO  : {text : 'No',  itemId : 'no'}, 
     // Add additional(localized) button configs here 

     // ICON CSS Constants 
     INFO  : 'x-msgbox-info', 
     WARNING : 'x-msgbox-warning', 
     QUESTION : 'x-msgbox-question', 
     ERROR : 'x-msgbox-error' 
    }); 

    Ext.apply(B, { 
     OKCANCEL : [B.CANCEL, B.OK], 
     YESNOCANCEL : [B.CANCEL, B.NO, B.YES], 
     YESNO  : [B.NO, B.YES] 
     // Add additional button collections here 
    }); 

})(); 

您可以使用Ext.override在自己的應用程序重寫此功能:

Ext.override(Ext.MessageBox, { 
    YESNO: [Ext.MessageBox.YES, Ext.MessageBox.NO] 
}); 
+0

對我的作品,謝謝! – RynoRn

+0

嗨,肯,你知道如何用特殊字符覆蓋,例如西里爾文? – inane

+0

恐怕我幫不了你!自2011年以來,我一直沒有與Sencha Touch合作!我已upvoted您的帖子在http://stackoverflow.com/questions/31564533/cyrillic-characters-in-messagebox-class-of-sencha-touch –

2

這是很容易試試這個

Ext.Msg.confirm("Logout", "Are you Sure u want to LogOut?", function(btn){ 
    if (btn == 'yes'){ 
    Ext.Viewport.setActiveItem({xtype:"Home"}); // which page wants to redirect 
    } 
}); 
1

我想這一點,和我的作品:

嘗試這種解決方案:

<script type="text/javascript"> 
    (function() { 
     Ext.override(Ext.MessageBox, { 
      buttonText: { yes: "Sí", no: "No", cancel: "Cancelar" } 
     }); 
     })(); 
</script> 
3

您可以覆蓋像ST2.1下面的代碼,還可以在YES /使用該否按鈕實現本地化。

Ext.MessageBox.override({ 
     confirm: function(title, message, fn, scope) { 
     return this.show({ 
      title  : title || null, 
      message  : message || null, 
      buttons  : [ 
      {text: 'Yes', itemId: 'yes', ui: 'action'}, 
      {text: 'No', itemId: 'no'} 
     ], 
      promptConfig: false, 
      scope  : scope, 
      fn: function() { 
       if (fn) { 
        fn.apply(scope, arguments); 
       } 
      } 
     }); 
    } 

     }); 
+1

這是Sencha Touch 2.3在此線程中唯一的工作解決方案! –

0
Ext.Msg.show({ 
        title: '提示', 
        message: '是否繼續?', 
        width: 300, 
        buttons: [ 
         {text: '是', itemId: 'yes', ui: 'action'}, 
         {text: '否', itemId: 'no'} 
        ], 
        fn: function (buttonId) { 
         alert('You pressed the "' + buttonId + '" button.'); 
        } 
       }); 
相關問題