Search code examples
extjsconfirmbutton

Yes/No buttons in Confirm box in Sencha touch


I have put a confirm box on the logout option of my application. Code for the same is as follows:

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

No button of the confirm box is visible before the yes button.

How can I display Yes button before the No Button?

Any help is appreciated.


Solution

  • According to the sencha touch source code ( http://docs.sencha.com/touch/1-1/source/MessageBox.html#Ext-MessageBox-method-confirm ) YESNO is defined as "no, yes":

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

    You can use Ext.override to override this functionality in your own app:

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