1 <div class="body-wrap" xmlns:ext="http://www.extjs.com"><div class="top-tools"><a class="inner-link" href="#Ext.util.Functions-props"><img src="resources/images/default/s.gif" class="item-icon icon-prop">Properties</a> <a class="inner-link" href="#Ext.util.Functions-methods"><img src="resources/images/default/s.gif" class="item-icon icon-method">Methods</a> <a class="inner-link" href="#Ext.util.Functions-events"><img src="resources/images/default/s.gif" class="item-icon icon-event">Events</a> <a class="bookmark" href="../docs/?class=Ext.util.Functions"><img src="resources/images/default/s.gif" class="item-icon icon-fav">Direct Link</a> </div><h1>Class <a href="source/Function.html#cls-Ext.util.Functions">Ext.util.Functions</a></h1><table cellspacing="0"><tr><td class="label">Package:</td><td class="hd-info">Ext.util</td></tr><tr><td class="label">Defined In:</td><td class="hd-info"><a href="source/Function.html#cls-Ext.util.Functions">Function.js</a></td></tr><tr><td class="label">Class:</td><td class="hd-info"><a href="source/Function.html#cls-Ext.util.Functions">Functions</a></td></tr><tr><td class="label">Extends:</td><td class="hd-info">Object</td></tr></table><div class="description"><br><br><i>This class is a singleton and cannot be created directly.</i></div><div class="hr"></div><a id="Ext.util.Functions-props"></a><h2>Public Properties</h2><div class="no-members">This class has no public properties.</div><a id="Ext.util.Functions-methods"></a><h2>Public Methods</h2><table cellspacing="0" class="member-table"><tbody><tr><th colspan="2" class="sig-header">Method</th><th class="msource-header">Defined By</th></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Functions-createDelegate"></a><b><a href="source/Function.html#method-Ext.util.Functions-createDelegate">createDelegate</a></b>( <code>Function fn</code>, <span title="Optional" class="optional">[<code>Object scope</code>]</span>, <span title="Optional" class="optional">[<code>Array args</code>]</span>, <span title="Optional" class="optional">[<code>Boolean/Number appendArgs</code>]</span> )
3 Function<div class="mdesc"><div class="short">Creates a delegate (callback) that sets the scope to obj.
4 Call directly on any function. Example: Ext.createDelegate(...</div><div class="long">Creates a delegate (callback) that sets the scope to obj.
5 Call directly on any function. Example: <code>Ext.createDelegate(this.myFunction, this, [arg1, arg2])</code>
6 Will create a function that is automatically scoped to obj so that the <tt>this</tt> variable inside the
7 callback points to obj. Example usage:
8 <pre><code><b>var</b> sayHi = <b>function</b>(name){
9 <i>// Note this use of <em>"this.text"</em> here. This <b>function</b> expects to</i>
10 <i>// execute within a scope that contains a text property. In this</i>
11 <i>// example, the <em>"this"</em> variable is pointing to the btn object that</i>
12 <i>// was passed <b>in</b> createDelegate below.</i>
13 alert(<em>'Hi, '</em> + name + <em>'. You clicked the <em>"'</em> + this.text + <em>'"</em> button.'</em>);
16 <b>var</b> btn = <b>new</b> Ext.Button({
17 text: <em>'Say Hi'</em>,
18 renderTo: Ext.getBody()
21 <i>// This callback will execute <b>in</b> the scope of the</i>
22 <i>// button instance. Clicking the button alerts</i>
23 <i>// <em>"Hi, Fred. You clicked the "</em>Say Hi<em>" button."</em></i>
24 btn.on(<em>'click'</em>, Ext.createDelegate(sayHi, btn, [<em>'Fred'</em>]));</code></pre><div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>fn</code> : Function<div class="sub-desc">The function to delegate.</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
25 <b>If omitted, defaults to the browser window.</b></div></li><li><code>args</code> : Array<div class="sub-desc">(optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)</div></li><li><code>appendArgs</code> : Boolean/Number<div class="sub-desc">(optional) if True args are appended to call args instead of overriding,
26 if a number the args are inserted at the specified position</div></li></ul><strong>Returns:</strong><ul><li><code>Function</code><div class="sub-desc">The new function</div></li></ul></div></div></div></td><td class="msource">Functions</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Functions-createInterceptor"></a><b><a href="source/Function.html#method-Ext.util.Functions-createInterceptor">createInterceptor</a></b>( <code>Function origFn</code>, <code>Function newFn</code>, <span title="Optional" class="optional">[<code>Object scope</code>]</span> )
28 Function<div class="mdesc"><div class="short">Creates an interceptor function. The passed function is called before the original one. If it returns false,
29 the orig...</div><div class="long">Creates an interceptor function. The passed function is called before the original one. If it returns false,
30 the original one is not called. The resulting function returns the results of the original function.
31 The passed function is called with the parameters of the original function. Example usage:
32 <pre><code><b>var</b> sayHi = <b>function</b>(name){
33 alert(<em>'Hi, '</em> + name);
36 sayHi(<em>'Fred'</em>); <i>// alerts <em>"Hi, Fred"</em></i>
38 <i>// create a <b>new</b> <b>function</b> that validates input without</i>
39 <i>// directly modifying the original <b>function</b>:</i>
40 <b>var</b> sayHiToFriend = Ext.createInterceptor(sayHi, <b>function</b>(name){
41 <b>return</b> name == <em>'Brian'</em>;
44 sayHiToFriend(<em>'Fred'</em>); <i>// no alert</i>
45 sayHiToFriend(<em>'Brian'</em>); <i>// alerts <em>"Hi, Brian"</em></i></code></pre><div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>origFn</code> : Function<div class="sub-desc">The original function.</div></li><li><code>newFn</code> : Function<div class="sub-desc">The function to call before the original</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (<code><b>this</b></code> reference) in which the passed function is executed.
46 <b>If omitted, defaults to the scope in which the original function is called or the browser window.</b></div></li></ul><strong>Returns:</strong><ul><li><code>Function</code><div class="sub-desc">The new function</div></li></ul></div></div></div></td><td class="msource">Functions</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Functions-createSequence"></a><b><a href="source/Function.html#method-Ext.util.Functions-createSequence">createSequence</a></b>( <code>Function origFn</code>, <code>Function newFn</code>, <span title="Optional" class="optional">[<code>Object scope</code>]</span> )
48 Function<div class="mdesc"><div class="short">Create a combined function call sequence of the original function + the passed function.
49 The resulting function retur...</div><div class="long">Create a combined function call sequence of the original function + the passed function.
50 The resulting function returns the results of the original function.
51 The passed fcn is called with the parameters of the original function. Example usage:
52 var sayHi = function(name){
56 sayHi('Fred'); // alerts "Hi, Fred"
58 var sayGoodbye = Ext.createSequence(sayHi, function(name){
59 alert('Bye, ' + name);
62 sayGoodbye('Fred'); // both alerts show<div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>origFn</code> : Function<div class="sub-desc">The original function.</div></li><li><code>newFn</code> : Function<div class="sub-desc">The function to sequence</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (this reference) in which the passed function is executed.
63 If omitted, defaults to the scope in which the original function is called or the browser window.</div></li></ul><strong>Returns:</strong><ul><li><code>Function</code><div class="sub-desc">The new function</div></li></ul></div></div></div></td><td class="msource">Functions</td></tr><tr class="method-row expandable "><td class="micon"><a href="#expand" class="exi"> </a></td><td class="sig"><a id="Ext.util.Functions-defer"></a><b><a href="source/Function.html#method-Ext.util.Functions-defer">defer</a></b>( <code>Function fn</code>, <code>Number millis</code>, <span title="Optional" class="optional">[<code>Object scope</code>]</span>, <span title="Optional" class="optional">[<code>Array args</code>]</span>, <span title="Optional" class="optional">[<code>Boolean/Number appendArgs</code>]</span> )
65 Number<div class="mdesc"><div class="short">Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
66 var say...</div><div class="long">Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
67 <pre><code><b>var</b> sayHi = <b>function</b>(name){
68 alert(<em>'Hi, '</em> + name);
71 <i>// executes immediately:</i>
72 sayHi(<em>'Fred'</em>);
74 <i>// executes after 2 seconds:</i>
75 Ext.defer(sayHi, 2000, this, [<em>'Fred'</em>]);
77 <i>// this syntax is sometimes useful <b>for</b> deferring</i>
78 <i>// execution of an anonymous <b>function</b>:</i>
79 Ext.defer(<b>function</b>(){
80 alert(<em>'Anonymous'</em>);
81 }, 100);</code></pre><div class="mdetail-params"><strong>Parameters:</strong><ul><li><code>fn</code> : Function<div class="sub-desc">The function to defer.</div></li><li><code>millis</code> : Number<div class="sub-desc">The number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately)</div></li><li><code>scope</code> : Object<div class="sub-desc">(optional) The scope (<code><b>this</b></code> reference) in which the function is executed.
82 <b>If omitted, defaults to the browser window.</b></div></li><li><code>args</code> : Array<div class="sub-desc">(optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller)</div></li><li><code>appendArgs</code> : Boolean/Number<div class="sub-desc">(optional) if True args are appended to call args instead of overriding,
83 if a number the args are inserted at the specified position</div></li></ul><strong>Returns:</strong><ul><li><code>Number</code><div class="sub-desc">The timeout id that can be used with clearTimeout</div></li></ul></div></div></div></td><td class="msource">Functions</td></tr></tbody></table><a id="Ext.util.Functions-events"></a><h2>Public Events</h2><div class="no-members">This class has no public events.</div></div>