Ext事件机制
先看看这里的说明:http://www.cnblogs.com/beginor/archive/2008/03/07/1095887.html
测试代码:
Employee = function(name) {
this.name = name;
this.addEvents({
"confirm" : true,
"quit" : true
});
this.confirmBeforeQuit();
};
Ext.extend(Employee, Ext.util.Observable, {
confirmBeforeQuit : function() {
this.on("quit", function(emp) {
this.fireEvent('confirm', this);
return false;
});
}
});
function quitHandler(emp) {
alert(emp.name + " 安全退出");
}
function confirmHandler(emp, eve) {
alert(emp.name + " 确认退出吗?");
}
var emp = new Employee('Tom');
emp.on('quit', quitHandler);
emp.on('confirm', confirmHandler);
emp.fireEvent("quit", emp);