PDA

View Full Version : Ext.MessageBox.prompt to password



icemanovich
30 Nov 2011, 6:05 AM
Hi,

I try to change default textField (input) in Ext.MessageBox.prompt dialog, but can't do this. This field should be launch when user click the button and try to upload file.

Search result give me this:
http://www.sencha.com/forum/showthread.php?28626-Ext.Msg-prompt-as-password-control
but it doesn't works.

Does any one knows how to do that?



Ext.MessageBox.prompt('login', 'input password:', function(btn, text){
if (btn === 'ok'){
var form = Ext.getCmp('formPanelManager').getForm();
if(form.isValid()){
form.submit({

url: 'controller/tab_manage/uploadConfig.php',
params: { upas: text },
success: function(fp, o) {

console.info(o);
if ( o.result.success == "true") {
// success
} else if(o.result.success != true) {
// error
}
}
});
Ext.getCmp('panelUpdate').items.items[0].value = '';
}
}
});



Thanks.

Araberen
30 Nov 2011, 9:13 AM
You can't. Take a look at the prompt method:

prompt : function(cfg, msg, fn, scope, multiline, value){
if (Ext.isString(cfg)) {
cfg = {
prompt: true,
title: cfg,
minWidth: this.minPromptWidth,
msg: msg,
buttons: this.OKCANCEL,
callback: fn,
scope: scope,
multiline: multiline,
value: value
};
}
return this.show(cfg);
}

Enjoy my solution:


var w = Ext.MessageBox.show({
prompt: true,
title: 'Prompt',
msg: 'msg',
buttons: Ext.MessageBox.OKCANCEL
});
w.getEl().dom.children[1].children[0].children[1].children[1].children[0].children[0].setAttribute('type', 'password');

^^

mitchellsimoens
30 Nov 2011, 9:17 AM
You are referencing a thread from Ext JS 2 so I wouldn't expect it to work.
Ext.window.MessageBox isn't very customizable. Simply, it already creates a textfield and you can't configure that textfield.


So it's not easy so since Ext.window.MessageBox extends Ext.window.Window and just adds components, you could just create your own Ext.window.Window

icemanovich
1 Dec 2011, 12:38 AM
As mitchellsimoens said,


So it's not easy so since Ext.window.MessageBox extends Ext.window.Window and just adds components, you could just create your own Ext.window.Window

I created my own Window with components and submit upload form by button click.



xtype: 'button',
id: 'confirmButton',
width: 75,
text: 'Ok',
margins: '0 10 0 0',
formBind: true,
handler: function(){
var form = this.up('form').getForm();
var ftext = form.getValues().upass;
var manageForm = Ext.getCmp('formPanelManager').getForm();
if(manageForm.isValid()){

manageForm.submit({
url: 'controller/tab_manage/uploadConfig.php',
params: { upass: ftext },
success: function(fp, o) {
console.info(o);
if ( o.result.success == "true") {
// MSG SUCCESS
} else if(o.result.success != true) {
// MSG ERROR
}
},
failure: function(form, action){
console.info("ERROR ", action); //...
Ext.MessageBox.show({title: 'Error.', msg: 'Error# <br />' + action.result.msg, buttons: Ext.MessageBox.OK, icon: Ext.MessageBox.ERROR});
}
});
Ext.getCmp('panelUpdate').items.items[0].value = '';
Ext.getCmp('confirmWindow').close();
}
}


P.S. Araberen, first of all, I thought the save way to get input component by call child[0] ...child[1] ...child... But this is dirty hack :)

Thanks for yours advices!