commit extjs-2.2.1
[extjs.git] / docs / output / Ext.util.Observable.html
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>
8         </div>
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>
16                     </table>
17         <div class="description">
18             *
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>
21 For example:
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
27     });
28  }
29  Ext.extend(Employee, Ext.util.Observable);</code></pre>        </div>
30         
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">
35             <tr>
36                 <th class="sig-header" colspan="2">Config Options</th>
37                 <th class="msource-header">Defined By</th>
38             </tr>
39                 <tr class="config-row expandable">\r
40         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
41         <td class="sig">\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
45             <div class="long">\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
47                         </div>\r
48         </td>\r
49         <td class="msource">Observable</td>\r
50     </tr>\r
51             </table>
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">
57             <tr>
58                 <th class="sig-header" colspan="2">Method</th>
59                 <th class="msource-header">Defined By</th>
60             </tr>
61                 <tr class="method-row expandable">\r
62         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
63         <td class="sig">\r
64         <a id="Ext.util.Observable-Observable.capture"></a>\r
65             <b>Observable.capture</b>(&nbsp;<code>Observable o</code>, <code>Function fn</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;) : void            <div class="mdesc">\r
66                         <div class="short">&lt;static&gt; Starts capture on the specified Observable. All events will be passed
67 to the supplied function with th...</div>\r
68             <div class="long">\r
69                 &lt;static&gt; 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
76         <ul>\r
77             <li><code>void</code></li>\r
78         </ul>\r
79     </div>\r
80                 </div>\r
81                         </div>\r
82         </td>\r
83         <td class="msource">Observable</td>\r
84     </tr>\r
85         <tr class="method-row alt expandable">\r
86         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
87         <td class="sig">\r
88         <a id="Ext.util.Observable-Observable.releaseCapture"></a>\r
89             <b>Observable.releaseCapture</b>(&nbsp;<code>Observable o</code>&nbsp;) : void            <div class="mdesc">\r
90                         <div class="short">&lt;static&gt; Removes <b>all</b> added captures from the Observable.</div>\r
91             <div class="long">\r
92                 &lt;static&gt; 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
96         <ul>\r
97             <li><code>void</code></li>\r
98         </ul>\r
99     </div>\r
100                 </div>\r
101                         </div>\r
102         </td>\r
103         <td class="msource">Observable</td>\r
104     </tr>\r
105         <tr class="method-row expandable">\r
106         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
107         <td class="sig">\r
108         <a id="Ext.util.Observable-addEvents"></a>\r
109             <b>addEvents</b>(&nbsp;<code>Object object</code>&nbsp;) : void            <div class="mdesc">\r
110                         <div class="short">Used to define events on this Observable</div>\r
111             <div class="long">\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
116         <ul>\r
117             <li><code>void</code></li>\r
118         </ul>\r
119     </div>\r
120                 </div>\r
121                         </div>\r
122         </td>\r
123         <td class="msource">Observable</td>\r
124     </tr>\r
125         <tr class="method-row alt expandable">\r
126         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
127         <td class="sig">\r
128         <a id="Ext.util.Observable-addListener"></a>\r
129             <b>addListener</b>(&nbsp;<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>&nbsp;) : void            <div class="mdesc">\r
130                         <div class="short">Appends an event handler to this component</div>\r
131             <div class="long">\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>
143 </ul><br>
144 <p>
145 <b>Combining Options</b><br>
146 Using the options argument, it is possible to combine different types of listeners:<br>
147 <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>, {
150     single: true,
151     delay: 100,
152     forumId: 4
153 });</code></pre>
154 <p>
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.
158 <p>
159 <pre><code>foo.on({
160     <em>'click'</em> : {
161         fn: <b>this</b>.onClick,
162         scope: <b>this</b>,
163         delay: 100
164     },
165     <em>'mouseover'</em> : {
166         fn: <b>this</b>.onMouseOver,
167         scope: <b>this</b>
168     },
169     <em>'mouseout'</em> : {
170         fn: <b>this</b>.onMouseOut,
171         scope: <b>this</b>
172     }
173 });</code></pre>
174 <p>
175 Or a shorthand syntax:<br>
176 <pre><code>foo.on({
177     <em>'click'</em> : <b>this</b>.onClick,
178     <em>'mouseover'</em> : <b>this</b>.onMouseOver,
179     <em>'mouseout'</em> : <b>this</b>.onMouseOut,
180      scope: <b>this</b>
181 });</code></pre></div></li>        </ul>\r
182         <strong>Returns:</strong>\r
183         <ul>\r
184             <li><code>void</code></li>\r
185         </ul>\r
186     </div>\r
187                 </div>\r
188                         </div>\r
189         </td>\r
190         <td class="msource">Observable</td>\r
191     </tr>\r
192         <tr class="method-row expandable">\r
193         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
194         <td class="sig">\r
195         <a id="Ext.util.Observable-fireEvent"></a>\r
196             <b>fireEvent</b>(&nbsp;<code>String eventName</code>, <code>Object... args</code>&nbsp;) : Boolean            <div class="mdesc">\r
197                         <div class="short">Fires the specified event with the passed parameters (minus the event name).</div>\r
198             <div class="long">\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
203         <ul>\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
205         </ul>\r
206     </div>\r
207                 </div>\r
208                         </div>\r
209         </td>\r
210         <td class="msource">Observable</td>\r
211     </tr>\r
212         <tr class="method-row alt expandable">\r
213         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
214         <td class="sig">\r
215         <a id="Ext.util.Observable-hasListener"></a>\r
216             <b>hasListener</b>(&nbsp;<code>String eventName</code>&nbsp;) : Boolean            <div class="mdesc">\r
217                         <div class="short">Checks to see if this object has any listeners for a specified event</div>\r
218             <div class="long">\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
223         <ul>\r
224             <li><code>Boolean</code><div class="sub-desc">True if the event is being listened for, else false</div></li>\r
225         </ul>\r
226     </div>\r
227                 </div>\r
228                         </div>\r
229         </td>\r
230         <td class="msource">Observable</td>\r
231     </tr>\r
232         <tr class="method-row expandable">\r
233         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
234         <td class="sig">\r
235         <a id="Ext.util.Observable-on"></a>\r
236             <b>on</b>(&nbsp;<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>&nbsp;) : void            <div class="mdesc">\r
237                         <div class="short">Appends an event handler to this element (shorthand for addListener)</div>\r
238             <div class="long">\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
244         <ul>\r
245             <li><code>void</code></li>\r
246         </ul>\r
247     </div>\r
248                 </div>\r
249                         </div>\r
250         </td>\r
251         <td class="msource">Observable</td>\r
252     </tr>\r
253         <tr class="method-row alt expandable">\r
254         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
255         <td class="sig">\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
259             <div class="long">\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
264         <ul>\r
265             <li><code>void</code></li>\r
266         </ul>\r
267     </div>\r
268                 </div>\r
269                         </div>\r
270         </td>\r
271         <td class="msource">Observable</td>\r
272     </tr>\r
273         <tr class="method-row expandable">\r
274         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
275         <td class="sig">\r
276         <a id="Ext.util.Observable-relayEvents"></a>\r
277             <b>relayEvents</b>(&nbsp;<code>Object o</code>, <code>Array events</code>&nbsp;) : 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
279             <div class="long">\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
284         <ul>\r
285             <li><code>void</code></li>\r
286         </ul>\r
287     </div>\r
288                 </div>\r
289                         </div>\r
290         </td>\r
291         <td class="msource">Observable</td>\r
292     </tr>\r
293         <tr class="method-row alt expandable">\r
294         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
295         <td class="sig">\r
296         <a id="Ext.util.Observable-removeListener"></a>\r
297             <b>removeListener</b>(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;) : void            <div class="mdesc">\r
298                         <div class="short">Removes a listener</div>\r
299             <div class="long">\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
304         <ul>\r
305             <li><code>void</code></li>\r
306         </ul>\r
307     </div>\r
308                 </div>\r
309                         </div>\r
310         </td>\r
311         <td class="msource">Observable</td>\r
312     </tr>\r
313         <tr class="method-row expandable">\r
314         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
315         <td class="sig">\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
319             <div class="long">\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
324         <ul>\r
325             <li><code>void</code></li>\r
326         </ul>\r
327     </div>\r
328                 </div>\r
329                         </div>\r
330         </td>\r
331         <td class="msource">Observable</td>\r
332     </tr>\r
333         <tr class="method-row alt expandable">\r
334         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
335         <td class="sig">\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
339             <div class="long">\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
344         <ul>\r
345             <li><code>void</code></li>\r
346         </ul>\r
347     </div>\r
348                 </div>\r
349                         </div>\r
350         </td>\r
351         <td class="msource">Observable</td>\r
352     </tr>\r
353         <tr class="method-row expandable">\r
354         <td class="micon"><a class="exi" href="#expand">&nbsp;</a></td>\r
355         <td class="sig">\r
356         <a id="Ext.util.Observable-un"></a>\r
357             <b>un</b>(&nbsp;<code>String eventName</code>, <code>Function handler</code>, <span class="optional" title="Optional">[<code>Object scope</code>]</span>&nbsp;) : void            <div class="mdesc">\r
358                         <div class="short">Removes a listener (shorthand for removeListener)</div>\r
359             <div class="long">\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
364         <ul>\r
365             <li><code>void</code></li>\r
366         </ul>\r
367     </div>\r
368                 </div>\r
369                         </div>\r
370         </td>\r
371         <td class="msource">Observable</td>\r
372     </tr>\r
373             </table>
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>
377         </div>