今天把一个button放在了Ext.Window中,想用button确定window对象。n就没尝试成功。一开始用
发现一切OK。然后开始取window
发现一直取不到值。狂晕中采用如下方法
buttons:[{
text:'确定',
handler:function(){
alert(alert(this.ownerCt.ownerCt.title);
}
}]
竟然OK了。难道是我没理解正确。
完整代码如下:
Js代码
Ext.onReady(function(){
var _window = new Ext.Window({
title:'登录',
layout:'form',
280,
height:150,
labelWidth:50,
plain:true,
defaults:{180},
bodyStyle:'padding:3px',
items:[{
xtype:'textfield',
fieldLabel:'姓名',
id:'username'
},{
xtype:'textfield',
fieldLabel:'密码',
type:'password'
}],
buttons:[{
text:'确定',
handler:function(){
alert(this.ownerCt.ownerCt.items.first().getValue());
alert(this.ownerCt.ownerCt.items.itemAt(0).getValue());
alert(Ext.getCmp("username").getValue());
//alert(this.text);this就是公布handler的对象
}
}]
});
_window.show();
});