1. #1
    Sencha User
    Join Date
    Dec 2010
    Posts
    15
    Vote Rating
    2
    dmassiani is on a distinguished road

      0  

    Default [resolved] Ext Msg Confirm change button text

    [resolved] Ext Msg Confirm change button text


    Hi,

    How i can change the button text ? (yes and no)

    Code:
    handler: function(){
    	Ext.Msg.confirm("Etes vous sûr", "", function(e){if(e == 'yes'){
    		Ext.getCmp('main').setActiveItem(6);	
    	}
    });
    }
    thanks in advance.
    Last edited by dmassiani; 29 Dec 2010 at 8:21 AM. Reason: resolved

  2. #2
    Touch Premium Member
    Join Date
    May 2007
    Posts
    23
    Vote Rating
    1
    Salva is on a distinguished road

      0  

    Default


    Hi dmassiani,

    I don't know if it's the proper way, but this is how I've finally done it:

    Code:
    if(Ext.MessageBox) {
              var MB = Ext.MessageBox;
              Ext.apply(MB, {
                        YES: { text: 'Sí', itemId: 'yes', ui: 'action' }
              });
     
              Ext.apply(MB, {
                        YESNO: [Ext.MessageBox.NO, Ext.MessageBox.YES]
              });
    }
    I just changed the 'Yes' button, as 'No' is the same in Spanish, but you could also change it. Have a look at lines 39875 - 39894 in sencha-touch-debug-w-comments.js (1.0.1) and you'll see the properties you have to override to change the default texts.

  3. #3
    Sencha User
    Join Date
    Dec 2010
    Posts
    15
    Vote Rating
    2
    dmassiani is on a distinguished road

      2  

    Default


    yes that's done

    i have do that :
    Code:
    var MB = Ext.MessageBox;
    Ext.apply(MB, {
    		YES: { text: 'Oui', itemId: 'yes', ui: 'action' }
    });
    Ext.apply(MB, {
    		NO: { text: 'Non', itemId: 'no' }
    });
    Ext.apply(MB, {
    		YESNO: [Ext.MessageBox.NO, Ext.MessageBox.YES]
    });
    thank you

  4. #4
    Touch Premium Member
    Join Date
    May 2007
    Posts
    23
    Vote Rating
    1
    Salva is on a distinguished road

      1  

    Default


    If you want to make it shorter,

    Code:
    var MB = Ext.MessageBox;
    Ext.apply(MB, {
    		YES: { text: 'Oui', itemId: 'yes', ui: 'action' },
    		NO: { text: 'Non', itemId: 'no' }
    });
    Ext.apply(MB, {
    		YESNO: [MB.NO, MB.YES]
    });
    Should also work. Only YESNO has to be applied after YES and NO have been assigned, as it references them and if you did it in the same "apply" method their values would still be the old ones.
    Ext.MessageBox could also be shortened to MB in the second Ext.apply (I made the mistake when writing the example code).

  5. #5
    Sencha User
    Join Date
    Dec 2010
    Posts
    15
    Vote Rating
    2
    dmassiani is on a distinguished road

      0  

    Default


    thanks you very much.
    i appreciate your answer

  6. #6
    Sencha Premium Member
    Join Date
    Jul 2012
    Posts
    26
    Vote Rating
    1
    alile is on a distinguished road

      0  

    Default


    I found this solution which I find to be more preferable: http://www.epiphanydigital.biz/2011/...ustom-buttons/

    PHP Code:
    Ext.Msg.show({ 
         
    title   'Enter Email Address'
         
    msg     null
         
    buttons : [{ 
              
    itemId 'ok',  
              
    text   'Send',   
              
    ui     'action' 
          
    },{   
              
    itemId 'cancel',   
              
    text   'Cancel'    
          
    }], 
          
    prompt  : {   
              
    maxlength 180,   
              
    autocapitalize false },   
              
    fn      : function(text,btn) {    // do some stuff  }  
          
    }); 

  7. #7
    Sencha User
    Join Date
    Nov 2012
    Posts
    1
    Vote Rating
    0
    EmilMatei is on a distinguished road

      0  

    Default I have another way

    I have another way


    Ext.MessageBox.prompt() is using Ext.MessageBox object properties, like buttonText.

    If you do something like this :

    var promptBox = Ext.Msg;
    promptBox.buttonText={
    cancel: 'cancelText',
    no: 'noText',
    ok: 'okText',
    yes: 'yesText'
    };

    If you call :
    promptBox.prompt(title, message, callback)

    OK and CANCEL buttons are displayed with their text label.

    Tested in ExtJs 3.2

  8. #8
    Sencha Premium Member
    Join Date
    Aug 2013
    Location
    Brazil
    Posts
    5
    Vote Rating
    0
    renatorro is on a distinguished road

      0  

    Default


    I think the proper way to do that is by overriding the default texts of MessageBox, just like the ExtJS's "ext-locale" package:

    Code:
    Ext.define("PIM.overrides.MessageBox", {
        override: "Ext.MessageBox",
        statics: {
            OK    : {text: 'OK',     itemId: 'ok',  ui: 'action'},
            YES   : {text: 'Sim',    itemId: 'yes', ui: 'action'},
            NO    : {text: 'Não',     itemId: 'no'},
            CANCEL: {text: 'Cancelar', itemId: 'cancel'},
    
            INFO    : Ext.baseCSSPrefix + 'msgbox-info',
            WARNING : Ext.baseCSSPrefix + 'msgbox-warning',
            QUESTION: Ext.baseCSSPrefix + 'msgbox-question',
            ERROR   : Ext.baseCSSPrefix + 'msgbox-error',
    
            OKCANCEL: [
                {text: 'Cancelar', itemId: 'cancel'},
                {text: 'OK',     itemId: 'ok',  ui : 'action'}
            ],
            YESNOCANCEL: [
                {text: 'Cancelar', itemId: 'cancel'},
                {text: 'Não',     itemId: 'no'},
                {text: 'Sim',    itemId: 'yes', ui: 'action'}
            ],
            YESNO: [
                {text: 'Não',  itemId: 'no'},
                {text: 'Sim', itemId: 'yes', ui: 'action'}
            ]
        }
    });

Similar Threads

  1. [CLOSED] Ext.Msg.confirm - YES/NO Order
    By phroggar in forum Sencha Touch 1.x: Bugs
    Replies: 0
    Last Post: 9 Nov 2010, 5:34 AM
  2. Ext.Msg.confirm not passing which button pressed
    By mikeyroy in forum Sencha Touch 1.x: Discussion
    Replies: 4
    Last Post: 26 Oct 2010, 11:00 PM
  3. Desktop from example and Ext.Msg.confirm
    By evgenspb in forum Ext 3.x: Help & Discussion
    Replies: 1
    Last Post: 13 Aug 2010, 12:02 AM
  4. waiting for asynchronous Ext.msg.Confirm
    By randomuser01 in forum Ext 2.x: Help & Discussion
    Replies: 0
    Last Post: 2 Oct 2008, 11:32 AM
  5. Replies: 0
    Last Post: 16 May 2008, 9:18 AM

Thread Participants: 4