2

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.

Jammy
  • 35
  • 1
  • 2
  • 9

5 Answers5

4

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]
});
ByteWelder
  • 5,464
  • 1
  • 38
  • 45
  • Hi Ken, do you know how to override with special characters, for example cyrillic? – inane Jul 22 '15 at 14:40
  • I'm afraid I can't help you with that! I haven't worked with Sencha Touch since 2011! I have upvoted your post at http://stackoverflow.com/questions/31564533/cyrillic-characters-in-messagebox-class-of-sencha-touch – ByteWelder Jul 22 '15 at 14:47
3

You can override like the below code in ST2.1, Can also implement localization in YES/NO buttons using this.

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

        });
Manu Janardhanan
  • 600
  • 4
  • 10
2

It is Very easy Try this

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
  }
});
mr.VVoo
  • 2,265
  • 20
  • 30
Gayathri Mohan
  • 2,924
  • 4
  • 19
  • 25
1

I tried this, and works for me:

Try this solution:

<script type="text/javascript">
     (function () {
        Ext.override(Ext.MessageBox, {
            buttonText: { yes: "Sí", no: "No", cancel: "Cancelar" }
        });
      })();
</script>
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.');
                    }
                });