ExtJS 4 or 4.1 MessageBox Custom Buttons

Ekrem OĞUL picture Ekrem OĞUL · Sep 4, 2012 · Viewed 14.8k times · Source
Ext.MessageBox.show({
    title:'Messagebox Title',
    msg: 'Are you sure want to delete?',
    buttons: {yes: "Some Button 1",no: "Some Button 2",cancel: "Some Button 3"}
});

ExtJS 4 or 4.1 does not support this code. Buttons do not show.

Answer

user1766719 picture user1766719 · Oct 22, 2012

Just found out how to do this, hopefully it helps someone. As you can see you can handle the buttons however you want. Note that the framework only has 4 buttons by default and that is a limitation that won't be easily overcome. In the source there are multiple loops hard coded from 0 to < 4.

Ext.MessageBox.show({
    title:'Messagebox Title',
    msg: 'Are you sure want to delete?',
    buttonText: {yes: "Some Button 1",no: "Some Button 2",cancel: "Some Button 3"},
    fn: function(btn){
        console.debug('you clicked: ',btn); //you clicked:  yes
    }
});