Sencha touch 为什么我的第二个Ext.Msg在第一个Ext.Msg之后立即关闭?
首先,这是我的代码:Sencha touch 为什么我的第二个Ext.Msg在第一个Ext.Msg之后立即关闭?,sencha-touch,Sencha Touch,首先,这是我的代码: Ext.Msg.show({ title: 'Username', msg: 'Please enter your username', buttons: Ext.MessageBox.OKCANCEL, prompt:{ maxlength : 180, autocapitalize : false }, modal: true, fn: function(buttonId, text) { console.
Ext.Msg.show({
title: 'Username',
msg: 'Please enter your username',
buttons: Ext.MessageBox.OKCANCEL,
prompt:{ maxlength : 180, autocapitalize : false },
modal: true,
fn: function(buttonId, text) {
console.log("OK ("+text+"), what is you password?");
if (buttonId == 'ok')
{
Ext.Msg.show({
title: 'Password',
msg: 'Please enter your password',
buttons: Ext.MessageBox.OKCANCEL,
prompt:{ maxlength : 180, autocapitalize : false },
modal: true,
fn: function(buttonId2, text2) {
if (buttonId == 'ok')
{
console.log("OK ("+text+", "+text2+"), attempting login..");
}
},
icon: Ext.MessageBox.INFO
});
}
},
icon: Ext.MessageBox.INFO
});
我的问题是,当我在第一个消息框上按OK时,第二个消息框出现不到一秒钟,然后也关闭,而我没有在第二个消息框上按OK
当然,理想情况下,我会在同一个Messagebox中显示用户名和密码输入,但我不知道如何做到这一点
感谢大家的帮助 您正在调用的Ext.Msg上的static show方法基本上重新配置了以前的MessageBox,因此在再次隐藏和显示时会感到困惑 您应该创建Ext.MessageBox类的新实例,并调用该对象的show方法,以便它使用独立实例
var msg = new Ext.MessageBox().show({
title: 'Username',
msg: 'Please enter your username',
buttons: Ext.MessageBox.OKCANCEL,
prompt:{ maxlength : 180, autocapitalize : false },
modal: true,
fn: function(buttonId, text) {
console.log("OK ("+text+"), what is you password?");
if (buttonId == 'ok')
{
var msg2 = new Ext.MessageBox().show({
title: 'Password',
msg: 'Please enter your password',
buttons: Ext.MessageBox.OKCANCEL,
prompt:{ maxlength : 180, autocapitalize : false },
modal: true,
fn: function(buttonId2, text2) {
if (buttonId == 'ok')
{
console.log("OK ("+text+", "+text2+"), attempting login..");
}
},
icon: Ext.MessageBox.INFO
});
}
},
icon: Ext.MessageBox.INFO
});
虽然这是可行的,但我建议您创建一个包含这两个字段的自定义表单面板,并以这种方式收集信息
希望这有帮助。
斯图尔特