ITeye博客

Ext事件机制

lixw · 2009-02-19 14:41 · WEB开发 · Markdown

先看看这里的说明: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);

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。