PDA

View Full Version : Message box is not showing up



mreenareddy
4 Jun 2013, 4:18 AM
Please let me know why messgage box is not showing up in the following code snippet. alert is poped-up but messagebox is not shown up.

function doMsg(message, title) {
Ext.Msg.show( {
title : title, msg : message, buttons : Ext.MessageBox.OKCANCEL, icon : Ext.MessageBox.INFO, fn:confirm
});
}



function duplicate(){
alert('message');
doMsg('message.','title');

}

mreenareddy
4 Jun 2013, 4:21 AM
duplicate fucntion is called on button action as follows,

var duplicateButton = Ext.create('Ext.button.Button',
{
text : 'Duplicate', handler : duplicateContent, id : 'duplicateButton', disabled : true
});

mreenareddy
4 Jun 2013, 5:35 AM
one more update on this,

I have some other message box mentioned below. I guess that is causing problem.

var savmsg = Ext.Msg.show( {
title : '', msg : 'Duplicating Contents...', icon : Ext.MessageBox.INFO
});
But how can I have two different message boxes in my code?

friend
4 Jun 2013, 8:53 AM
The message box is a singleton.

droessner
4 Jun 2013, 9:54 AM
Ext.Msg is a singleton so only one can be visible at a time.

You can create other instances of the message box by doing something like this:



Ext.create('Ext.window.MessageBox').show({
title: 'test',
msg: 'test',
buttons: Ext.MessageBox.OKCANCEL,
icon: Ext.MessageBox.INFO
});


However, you need to be careful when doing this because each message box stays in the DOM even after the window is closed. You are responsible for destroying it once you are done with it.

For example, you could do this so that the MessageBox is destroyed on a hide.


Ext.create('Ext.window.MessageBox', {
listeners: {
hide: function() {
this.destroy();
}
}
}).show({
title: 'test',
msg: 'test',
buttons: Ext.MessageBox.OKCANCEL,
icon: Ext.MessageBox.INFO
});