1 <div class="body-wrap">
2 <div class="top-tools">
3 <a class="inner-link" href="#Ext.util.Observable-props"><img src="../resources/images/default/s.gif" class="item-icon icon-prop">Properties</a>
4 <a class="inner-link" href="#Ext.util.Observable-methods"><img src="../resources/images/default/s.gif" class="item-icon icon-method">Methods</a>
5 <a class="inner-link" href="#Ext.util.Observable-events"><img src="../resources/images/default/s.gif" class="item-icon icon-event">Events</a>
6 <a class="inner-link" href="#Ext.util.Observable-configs"><img src="../resources/images/default/s.gif" class="item-icon icon-config">Config Options</a>
7 <a class="bookmark" href="../docs/?class=Ext.util.Observable"><img src="../resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a>
9 <h1>Class Ext.util.Observable</h1>
10 <table cellspacing="0">
11 <tr><td class="label">Package:</td><td class="hd-info">Ext.util</td></tr>
12 <tr><td class="label">Defined In:</td><td class="hd-info"><a href="../src/Observable.js" target="_blank">Observable.js</a></td></tr>
13 <tr><td class="label">Class:</td><td class="hd-info">Observable</td></tr>
14 <tr><td class="label">Subclasses:</td><td class="hd-info"><a ext:cls="Ext.Component" href="output/Ext.Component.html">Component</a>, <a ext:cls="Ext.History" href="output/Ext.History.html">History</a>, <a ext:cls="Ext.Resizable" href="output/Ext.Resizable.html">Resizable</a>, <a ext:cls="Ext.SplitBar" href="output/Ext.SplitBar.html">SplitBar</a>, <a ext:cls="Ext.Updater" href="output/Ext.Updater.html">Updater</a>, <a ext:cls="Ext.air.NativeObservable" href="output/Ext.air.NativeObservable.html">NativeObservable</a>, <a ext:cls="Ext.data.Connection" href="output/Ext.data.Connection.html">Connection</a>, <a ext:cls="Ext.data.DataProxy" href="output/Ext.data.DataProxy.html">DataProxy</a>, <a ext:cls="Ext.data.Node" href="output/Ext.data.Node.html">Node</a>, <a ext:cls="Ext.data.Store" href="output/Ext.data.Store.html">Store</a>, <a ext:cls="Ext.data.Tree" href="output/Ext.data.Tree.html">Tree</a>, <a ext:cls="Ext.form.BasicForm" href="output/Ext.form.BasicForm.html">BasicForm</a>, <a ext:cls="Ext.grid.AbstractSelectionModel" href="output/Ext.grid.AbstractSelectionModel.html">AbstractSelectionModel</a>, <a ext:cls="Ext.grid.ColumnModel" href="output/Ext.grid.ColumnModel.html">ColumnModel</a>, <a ext:cls="Ext.grid.GridView" href="output/Ext.grid.GridView.html">GridView</a>, <a ext:cls="Ext.grid.PropertyStore" href="output/Ext.grid.PropertyStore.html">PropertyStore</a>, <a ext:cls="Ext.menu.Menu" href="output/Ext.menu.Menu.html">Menu</a>, <a ext:cls="Ext.tree.DefaultSelectionModel" href="output/Ext.tree.DefaultSelectionModel.html">DefaultSelectionModel</a>, <a ext:cls="Ext.tree.MultiSelectionModel" href="output/Ext.tree.MultiSelectionModel.html">MultiSelectionModel</a>, <a ext:cls="Ext.tree.TreeLoader" href="output/Ext.tree.TreeLoader.html">TreeLoader</a>, <a ext:cls="Ext.util.ClickRepeater" href="output/Ext.util.ClickRepeater.html">ClickRepeater</a>, <a ext:cls="Ext.util.MixedCollection" href="output/Ext.util.MixedCollection.html">MixedCollection</a></td></tr>
15 <tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr>
17 <div class="description">
19 Abstract base class that provides a common interface for publishing events. Subclasses are expected to
20 to have a property "events" with all the events defined.<br>
22 <pre><code>Employee = <b>function</b>(name){
23 <b>this</b>.name = name;
24 <b>this</b>.addEvents({
25 <em>"fired"</em> : true,
26 <em>"quit"</em> : true
29 Ext.extend(Employee, Ext.util.Observable);</code></pre> </div>
31 <div class="hr"></div>
32 <a id="Ext.util.Observable-configs"></a>
33 <h2>Config Options</h2>
34 <table cellspacing="0" class="member-table">
36 <th class="sig-header" colspan="2">Config Options</th>
37 <th class="msource-header">Defined By</th>
39 <tr class="config-row expandable">
\r
40 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
42 <a id="Ext.util.Observable-listeners"></a>
\r
43 <b>listeners</b> : Object <div class="mdesc">
\r
44 <div class="short">(optional) A config object containing one or more event handlers to be added to this object during initialization. Th...</div>
\r
46 (optional) A config object containing one or more event handlers to be added to this object during initialization. This should be a valid listeners config object as specified in the <a ext:cls="Ext.util.Observable" ext:member="addListener" href="output/Ext.util.Observable.html#addListener">addListener</a> example for attaching multiple handlers at once. </div>
\r
49 <td class="msource">Observable</td>
\r
52 <a id="Ext.util.Observable-props"></a>
53 <h2>Public Properties</h2>
54 <div class="no-members">This class has no public properties.</div> <a id="Ext.util.Observable-methods"></a>
55 <h2>Public Methods</h2>
56 <table cellspacing="0" class="member-table">
58 <th class="sig-header" colspan="2">Method</th>
59 <th class="msource-header">Defined By</th>
61 <tr class="method-row expandable">
\r
62 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
64 <a id="Ext.util.Observable-Observable.capture"></a>
\r
65 <b>Observable.capture</b>( <code>Observable o</code>, <code>Function fn</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span> ) : void <div class="mdesc">
\r
66 <div class="short"><static> Starts capture on the specified Observable. All events will be passed
67 to the supplied function with th...</div>
\r
69 <static> Starts capture on the specified Observable. All events will be passed
70 to the supplied function with the event name + standard signature of the event
71 <b>before</b> the event is fired. If the supplied function returns false,
72 the event will not fire. <div class="mdetail-params">
\r
73 <strong>Parameters:</strong>
\r
74 <ul><li><code>o</code> : Observable<div class="sub-desc">The Observable to capture</div></li><li><code>fn</code> : Function<div class="sub-desc">The function to call</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (this object) for the fn</div></li> </ul>
\r
75 <strong>Returns:</strong>
\r
77 <li><code>void</code></li>
\r
83 <td class="msource">Observable</td>
\r
85 <tr class="method-row alt expandable">
\r
86 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
88 <a id="Ext.util.Observable-Observable.releaseCapture"></a>
\r
89 <b>Observable.releaseCapture</b>( <code>Observable o</code> ) : void <div class="mdesc">
\r
90 <div class="short"><static> Removes <b>all</b> added captures from the Observable.</div>
\r
92 <static> Removes <b>all</b> added captures from the Observable. <div class="mdetail-params">
\r
93 <strong>Parameters:</strong>
\r
94 <ul><li><code>o</code> : Observable<div class="sub-desc">The Observable to release</div></li> </ul>
\r
95 <strong>Returns:</strong>
\r
97 <li><code>void</code></li>
\r
103 <td class="msource">Observable</td>
\r
105 <tr class="method-row expandable">
\r
106 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
108 <a id="Ext.util.Observable-addEvents"></a>
\r
109 <b>addEvents</b>( <code>Object object</code> ) : void <div class="mdesc">
\r
110 <div class="short">Used to define events on this Observable</div>
\r
112 Used to define events on this Observable <div class="mdetail-params">
\r
113 <strong>Parameters:</strong>
\r
114 <ul><li><code>object</code> : Object<div class="sub-desc">The object with the events defined</div></li> </ul>
\r
115 <strong>Returns:</strong>
\r
117 <li><code>void</code></li>
\r
123 <td class="msource">Observable</td>
\r
125 <tr class="method-row alt expandable">
\r
126 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
128 <a id="Ext.util.Observable-addListener"></a>
\r
129 <b>addListener</b>( <code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>, <span class="optional" title="Optional">[<code>Object options</code>]</span> ) : void <div class="mdesc">
\r
130 <div class="short">Appends an event handler to this component</div>
\r
132 Appends an event handler to this component <div class="mdetail-params">
\r
133 <strong>Parameters:</strong>
\r
134 <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The method the event invokes</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope in which to execute the handler
135 function. The handler function's "this" context.</div></li><li><code>options</code> : Object<div class="sub-desc">(optional) An object containing handler configuration
136 properties. This may contain any of the following properties:<ul>
137 <li><b>scope</b> : Object<p class="sub-desc">The scope in which to execute the handler function. The handler function's "this" context.</p></li>
138 <li><b>delay</b> : Number<p class="sub-desc">The number of milliseconds to delay the invocation of the handler after the event fires.</p></li>
139 <li><b>single</b> : Boolean<p class="sub-desc">True to add a handler to handle just the next firing of the event, and then remove itself.</p></li>
140 <li><b>buffer</b> : Number<p class="sub-desc">Causes the handler to be scheduled to run in an <a ext:cls="Ext.util.DelayedTask" href="output/Ext.util.DelayedTask.html">Ext.util.DelayedTask</a> delayed
141 by the specified number of milliseconds. If the event fires again within that time, the original
142 handler is <em>not</em> invoked, but the new handler is scheduled in its place.</p></li>
145 <b>Combining Options</b><br>
146 Using the options argument, it is possible to combine different types of listeners:<br>
148 A normalized, delayed, one-time listener that auto stops the event and passes a custom argument (forumId)
149 <pre><code>el.on(<em>'click'</em>, <b>this</b>.onClick, <b>this</b>, {
155 <b>Attaching multiple handlers in 1 call</b><br>
156 The method also allows for a single argument to be passed which is a config object containing properties
157 which specify multiple handlers.
161 fn: <b>this</b>.onClick,
165 <em>'mouseover'</em> : {
166 fn: <b>this</b>.onMouseOver,
169 <em>'mouseout'</em> : {
170 fn: <b>this</b>.onMouseOut,
175 Or a shorthand syntax:<br>
177 <em>'click'</em> : <b>this</b>.onClick,
178 <em>'mouseover'</em> : <b>this</b>.onMouseOver,
179 <em>'mouseout'</em> : <b>this</b>.onMouseOut,
181 });</code></pre></div></li> </ul>
\r
182 <strong>Returns:</strong>
\r
184 <li><code>void</code></li>
\r
190 <td class="msource">Observable</td>
\r
192 <tr class="method-row expandable">
\r
193 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
195 <a id="Ext.util.Observable-fireEvent"></a>
\r
196 <b>fireEvent</b>( <code>String eventName</code>, <code>Object... args</code> ) : Boolean <div class="mdesc">
\r
197 <div class="short">Fires the specified event with the passed parameters (minus the event name).</div>
\r
199 Fires the specified event with the passed parameters (minus the event name). <div class="mdetail-params">
\r
200 <strong>Parameters:</strong>
\r
201 <ul><li><code>eventName</code> : String<div class="sub-desc"></div></li><li><code>args</code> : Object...<div class="sub-desc">Variable number of parameters are passed to handlers</div></li> </ul>
\r
202 <strong>Returns:</strong>
\r
204 <li><code>Boolean</code><div class="sub-desc">returns false if any of the handlers return false otherwise it returns true</div></li>
\r
210 <td class="msource">Observable</td>
\r
212 <tr class="method-row alt expandable">
\r
213 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
215 <a id="Ext.util.Observable-hasListener"></a>
\r
216 <b>hasListener</b>( <code>String eventName</code> ) : Boolean <div class="mdesc">
\r
217 <div class="short">Checks to see if this object has any listeners for a specified event</div>
\r
219 Checks to see if this object has any listeners for a specified event <div class="mdetail-params">
\r
220 <strong>Parameters:</strong>
\r
221 <ul><li><code>eventName</code> : String<div class="sub-desc">The name of the event to check for</div></li> </ul>
\r
222 <strong>Returns:</strong>
\r
224 <li><code>Boolean</code><div class="sub-desc">True if the event is being listened for, else false</div></li>
\r
230 <td class="msource">Observable</td>
\r
232 <tr class="method-row expandable">
\r
233 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
235 <a id="Ext.util.Observable-on"></a>
\r
236 <b>on</b>( <code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>, <span class="optional" title="Optional">[<code>Object options</code>]</span> ) : void <div class="mdesc">
\r
237 <div class="short">Appends an event handler to this element (shorthand for addListener)</div>
\r
239 Appends an event handler to this element (shorthand for addListener) <div class="mdetail-params">
\r
240 <strong>Parameters:</strong>
\r
241 <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The method the event invokes</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope in which to execute the handler
242 function. The handler function's "this" context.</div></li><li><code>options</code> : Object<div class="sub-desc">(optional)</div></li> </ul>
\r
243 <strong>Returns:</strong>
\r
245 <li><code>void</code></li>
\r
251 <td class="msource">Observable</td>
\r
253 <tr class="method-row alt expandable">
\r
254 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
256 <a id="Ext.util.Observable-purgeListeners"></a>
\r
257 <b>purgeListeners</b>() : void <div class="mdesc">
\r
258 <div class="short">Removes all listeners for this object</div>
\r
260 Removes all listeners for this object <div class="mdetail-params">
\r
261 <strong>Parameters:</strong>
\r
262 <ul><li>None.</li> </ul>
\r
263 <strong>Returns:</strong>
\r
265 <li><code>void</code></li>
\r
271 <td class="msource">Observable</td>
\r
273 <tr class="method-row expandable">
\r
274 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
276 <a id="Ext.util.Observable-relayEvents"></a>
\r
277 <b>relayEvents</b>( <code>Object o</code>, <code>Array events</code> ) : void <div class="mdesc">
\r
278 <div class="short">Relays selected events from the specified Observable as if the events were fired by <tt><b>this</b></tt>.</div>
\r
280 Relays selected events from the specified Observable as if the events were fired by <tt><b>this</b></tt>. <div class="mdetail-params">
\r
281 <strong>Parameters:</strong>
\r
282 <ul><li><code>o</code> : Object<div class="sub-desc">The Observable whose events this object is to relay.</div></li><li><code>events</code> : Array<div class="sub-desc">Array of event names to relay.</div></li> </ul>
\r
283 <strong>Returns:</strong>
\r
285 <li><code>void</code></li>
\r
291 <td class="msource">Observable</td>
\r
293 <tr class="method-row alt expandable">
\r
294 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
296 <a id="Ext.util.Observable-removeListener"></a>
\r
297 <b>removeListener</b>( <code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span> ) : void <div class="mdesc">
\r
298 <div class="short">Removes a listener</div>
\r
300 Removes a listener <div class="mdetail-params">
\r
301 <strong>Parameters:</strong>
\r
302 <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The handler to remove</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (this object) for the handler</div></li> </ul>
\r
303 <strong>Returns:</strong>
\r
305 <li><code>void</code></li>
\r
311 <td class="msource">Observable</td>
\r
313 <tr class="method-row expandable">
\r
314 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
316 <a id="Ext.util.Observable-resumeEvents"></a>
\r
317 <b>resumeEvents</b>() : void <div class="mdesc">
\r
318 <div class="short">Resume firing events. (see <a ext:cls="Ext.util.Observable" ext:member="suspendEvents" href="output/Ext.util.Observable.html#suspendEvents">suspendEvents</a>)</div>
\r
320 Resume firing events. (see <a ext:cls="Ext.util.Observable" ext:member="suspendEvents" href="output/Ext.util.Observable.html#suspendEvents">suspendEvents</a>) <div class="mdetail-params">
\r
321 <strong>Parameters:</strong>
\r
322 <ul><li>None.</li> </ul>
\r
323 <strong>Returns:</strong>
\r
325 <li><code>void</code></li>
\r
331 <td class="msource">Observable</td>
\r
333 <tr class="method-row alt expandable">
\r
334 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
336 <a id="Ext.util.Observable-suspendEvents"></a>
\r
337 <b>suspendEvents</b>() : void <div class="mdesc">
\r
338 <div class="short">Suspend the firing of all events. (see <a ext:cls="Ext.util.Observable" ext:member="resumeEvents" href="output/Ext.util.Observable.html#resumeEvents">resumeEvents</a>)</div>
\r
340 Suspend the firing of all events. (see <a ext:cls="Ext.util.Observable" ext:member="resumeEvents" href="output/Ext.util.Observable.html#resumeEvents">resumeEvents</a>) <div class="mdetail-params">
\r
341 <strong>Parameters:</strong>
\r
342 <ul><li>None.</li> </ul>
\r
343 <strong>Returns:</strong>
\r
345 <li><code>void</code></li>
\r
351 <td class="msource">Observable</td>
\r
353 <tr class="method-row expandable">
\r
354 <td class="micon"><a class="exi" href="#expand"> </a></td>
\r
356 <a id="Ext.util.Observable-un"></a>
\r
357 <b>un</b>( <code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span> ) : void <div class="mdesc">
\r
358 <div class="short">Removes a listener (shorthand for removeListener)</div>
\r
360 Removes a listener (shorthand for removeListener) <div class="mdetail-params">
\r
361 <strong>Parameters:</strong>
\r
362 <ul><li><code>eventName</code> : String<div class="sub-desc">The type of event to listen for</div></li><li><code>handler</code> : Function<div class="sub-desc">The handler to remove</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (this object) for the handler</div></li> </ul>
\r
363 <strong>Returns:</strong>
\r
365 <li><code>void</code></li>
\r
371 <td class="msource">Observable</td>
\r
374 <a id="Ext.util.Observable-events"></a>
375 <h2>Public Events</h2>
376 <div class="no-members">This class has no public events.</div>