{
xtype: 'button',
id : 'btnShowImage',
text : 'Show Image On List',
scale : 'large',
width : 200,
margin : '0 0 0 180',
}
var ShowImgBtn = Ext.get('btnShowImage');
ShowImgBtn.on('click', function(){
alert('hi');
});
怎么来不行?有什么问题?应该可以工作。
答案 0 :(得分:0)
您的代码正在运行:
Ext.onReady(function() {
Ext.create('Ext.Button', {
renderTo: Ext.getBody(),
id : 'btnShowImage',
text : 'Show Image On List',
scale : 'large',
width : 200,
margin : '0 0 0 180'
});
var ShowImgBtn = Ext.get('btnShowImage');
ShowImgBtn.on('click', function(){
alert('hi');
});
});
<强> http://jsfiddle.net/ht4UL/ 强>
可以是你的按钮没有渲染吗?
答案 1 :(得分:0)
将代码编辑为
Ext.getCmp('btnShowImage')
这是有效的。