什么是AttachEvent [英] For what is the AttachEvent

查看:139
本文介绍了什么是AttachEvent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我真的不明白类AttachEvent或addAttachHandler是什么。
这个有用的是什么?
可以有人发表一个例子吗?
Thx很多。

i really doesnt understand for what the class AttachEvent or the addAttachHandler is. For what is this usefull? could somebody post an example for that? Thx a lot.

推荐答案

当一个Widget从实际页面连接或分离时,AttachEvent会通知您。如果没有附加任何东西,它的元素就无法被看到或与其进行交互,因此知道它何时 不可用于交互可能是有益的。

The AttachEvent informs you when a Widget is either attached or detached from the actual page. If something isn't attached, there is no way its elements can be visible or interacted with, so it can be beneficial to know when it isn't available for interaction.

GWT自己使用这些知识的主要目的是为了连接事件处理代码。如果一个小部件没有连接到dom,它就不能与之交互,所以所有的处理程序都暂时脱离dom。这是作为GWT处理内存泄漏方法的一部分完成的(请参阅 http: //code.google.com/p/google-web-toolkit/wiki/DomEventsAndMemoryLeaks http://code.google.com/p/google-web-toolkit/wiki/UnderstandingMemoryLeaks 了解更多详情)。除非您在自己的dom侦听器中进行连线,或者为其他小部件构建容器,否则通常不需要担心这些细节。一个容器的主要职责之一就是告知它的子项已经被连接或分离。

The main thing that GWT itself uses this knowledge for is for wiring up event handling code. If a widget isn't attached to the dom, it can't be interacted with, so all handlers are temporarily detached from the dom. This is done as part of GWT's method for dealing with memory leaks (see http://code.google.com/p/google-web-toolkit/wiki/DomEventsAndMemoryLeaks and http://code.google.com/p/google-web-toolkit/wiki/UnderstandingMemoryLeaks for more details). You generally shouldn't need to worry about this detail, unless you are wiring in your own dom listeners, or building container for other widgets. One of the primary duties of a container is to inform its children when it has been attached or detached.

这篇关于什么是AttachEvent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆