DOM Events"

From Documentation
Line 27: Line 27:
 
},
 
},
 
</source>
 
</source>
 
  
 
Unlike jQuery's event listener (<javadoc directory="jsdoc">_global_.jq</javadoc>), <javadoc method="domListen_(_global_.DOMElement, _global_.String, zk.Object)" directory="jsdoc">zk.Widget</javadoc> will be ignored if the widget is under the control of ZK Weaver (a WYSIWYG editor), i.e., in the so-called ''Design Mode''. In most cases, a widget shall not register any event listener when it is under control of ZK Weaver to avoid any conflict.
 
Unlike jQuery's event listener (<javadoc directory="jsdoc">_global_.jq</javadoc>), <javadoc method="domListen_(_global_.DOMElement, _global_.String, zk.Object)" directory="jsdoc">zk.Widget</javadoc> will be ignored if the widget is under the control of ZK Weaver (a WYSIWYG editor), i.e., in the so-called ''Design Mode''. In most cases, a widget shall not register any event listener when it is under control of ZK Weaver to avoid any conflict.

Revision as of 10:42, 20 December 2010


A DOM event (Event) is the DOM-level event that is usually triggered by the browser. It is usually listened by the implementation of a widget, rather than the client application.

Since ZK Client Engine intercepts most DOM events and encapsulate them into the widget events, it is suggested to listen the widget events, if possible, for better performance (by overriding the corresponding methods, such as Widget.doClick_(Event)). For more information, please refer to the previous section.

How to Listen and Unlisten

There are two different approaches to listen a DOM event: Widget.domListen_(DOMElement, String, Object) and jQuery (jq).

Use domListen_ and domUnlisten_

Widget.domListen_(DOMElement, String, Object) registers a DOM-level event listener. The registration shall be done when a widget is bound to DOM elements, i.e., when Widget.bind_(Desktop, Skipper, Array) is called. It is important to un-register by use of Widget.domUnlisten_(DOMElement, String, Object) when a widget is un-bound from DOM elements, i.e., when Widget.unbind_(Skipper, Array) is called. For example,

bind_: function () {
 this.$supers('bind_', arguments);
 this.domListen_(this.getNode(), "onChange");
},
unbind_: function () {
 this.domUnlisten_(this.node, "onChange");
 this.$supers('unbind_', arguments);
},
_doChange: function (evt) { //event listener
},

Unlike jQuery's event listener (jq), Widget.domListen_(DOMElement, String, Object) will be ignored if the widget is under the control of ZK Weaver (a WYSIWYG editor), i.e., in the so-called Design Mode. In most cases, a widget shall not register any event listener when it is under control of ZK Weaver to avoid any conflict.

Use jQuery

When to Listen and Unlisten

Version History

Last Update : 2010/12/20


Version Date Content
     



Last Update : 2010/12/20

Copyright © Potix Corporation. This article is licensed under GNU Free Documentation License.