开发者

JavaScript event binding level 1 or level 2?

Since IE 开发者_高级运维does not support event capturing, is it a waste of time using W3C event binding techniques?

I'm thinking of just going with the level 1 event binding here - http://dean.edwards.name/weblog/2005/10/add-event/ , but I'm having a hard time understanding the need for the hash tabling.


You'll kill yourself implementing your own event system. Just use jQuery's. It's going to be better than anything you'll come up with unless you spend dedicated years on it.

The reason for hash tables is so the event handlers attached can be referenced easily and removed, and can be tracked down easily as well.

To removeEventListener you have to have a reference to the function. If you fed an anonymous one, you don't have a reference to it. That is why the hash tables map the events to the event handlers internally so you don't have to.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜