Ext.MyPanel=Ext.extend(Ext.Panel ,{
xtype:"panel",
title:"我的面板",
id:"mypanel",
renderTo:Ext.getBody(),
width:400,
height:250,
layout:"form",
initComponent: function(){
this.items=[
{
xtype:"textfield",
id:"txt",
renderTo:Ext.get("mypanel"),
fieldLabel:"标签",
anchor:"100%"
},
{
xtype:"button",
id:"btn",
text:"我的按钮"
}
]
Ext.MyPanel.superclass.initComponent.call(this);
}
});
Ext.onReady(function(){
var win= new Ext.MyPanel();
var btn=Ext.get("btn");
btn.on("click",function(){
alert(Ext.get("txt").value);//值取不到
alert(document.getElementById("txt").value);//值能取到
})
});
xtype:"panel",
title:"我的面板",
id:"mypanel",
renderTo:Ext.getBody(),
width:400,
height:250,
layout:"form",
initComponent: function(){
this.items=[
{
xtype:"textfield",
id:"txt",
renderTo:Ext.get("mypanel"),
fieldLabel:"标签",
anchor:"100%"
},
{
xtype:"button",
id:"btn",
text:"我的按钮"
}
]
Ext.MyPanel.superclass.initComponent.call(this);
}
});
Ext.onReady(function(){
var win= new Ext.MyPanel();
var btn=Ext.get("btn");
btn.on("click",function(){
alert(Ext.get("txt").value);//值取不到
alert(document.getElementById("txt").value);//值能取到
})
});
是正解。