ExtJs 自定义组件事件绑定
优化了一下代码,结果如下。
调用:
<script type="text/javascript">
function aaa(){
var student_panel = new WX.student.AddStudent({
callback_fun:function(){
alert("我是页面的方法");
}
}).show();
}
</script>
组件定义
Ext.define('WX.student.AddStudent', {
extend: 'Ext.window.Window',
modal:true,
height: 585,
width: 590,
layout: {
type: 'fit'
},
title: '新增学生',
//用于组件函数回调
callback_fun:function(){},
initComponent: function() {
var me = this;
Ext.applyIf(me, {
items: [
{
waitTitle: '加载中...',
items: [
......
],
buttons:[{
text:'保存',
scope:this, // <============== 关键参数
handler:function(){
//DO SOMETHING...
alert("组件的事件");
this.callback_fun();
}
}]
}
]
});
me.callParent(arguments);
}
});
浙公网安备 33010602011771号