PDA

View Full Version : Overriding prompt message



shinkenno
21 Jun 2010, 12:13 AM
Hi,

I want to override the prompt message box in order to change the displayed buttons and to add an icon (like the alert message box). I was trying this:



Ext.override(Ext.MessageBox, {
prompt : function(title, msg, btn, myicn, fn, scope, multiline, value){
this.show({
title : title,
msg : msg,
buttons: btn,
fn: fn,
minWidth: this.minPromptWidth,
scope : scope,
prompt:true,
multiline: multiline,
value: value,
icon : myicn
})
return this;
}
});


And when I call it like this:


Ext.MessageBox.prompt('MyTitle', 'Blabla...Description of something...', Ext.MessageBox.OK, Ext.MessageBox.ERROR, myCallbackFunction);

...it does not seem to override the initial prompt box (no icon, still 'OK/CANCEL' buttons, multiline prompt,...).

Do I code something wrong here ?
Thanks for your answers,

Best regards,
Arnaud

shinkenno
21 Jun 2010, 12:28 AM
After not too much digging into the ExtJS forums, I found the solution here:
http://www.sencha.com/forum/showthread.php?47491-Ext.override()-error&highlight=ext.override

Since Ext.MessageBox is a singleton, the idea is to use Ext.apply instead of Ext.override.