| createCallback()
+These functions are available on every Function object (any JavaScript function). Public PropertiesThis class has no public properties. Public Methods|
| createCallback()
:
- FunctionCreates a callback that passes arguments[0], arguments[1], arguments[2], ...
-Call directly on any function. Example:... Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
-Call directly on any function. Example: myFunction.createCallback(arg1, arg2)
-Will create a function that is bound to those 2 args. If a specific scope is required in the
-callback, use createDelegate instead. The function returned by createCallback always
-executes in the window scope.
- This method is required when you want to pass arguments to a callback function. If no arguments
-are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn).
-However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function
-would simply execute immediately when the code is parsed. Example usage:
- var sayHi = function(name){
- alert('Hi, ' + name);
-}
-
-// clicking the button alerts "Hi, Fred"
-new Ext.Button({
- text: 'Say Hi',
- renderTo: Ext.getBody(),
- handler: sayHi.createCallback('Fred')
-});
| Function | | createDelegate( [Object obj ], [Array args ], [Boolean/Number appendArgs ] )
+ FunctionCreates a callback that passes arguments[0], arguments[1], arguments[2], ...
+Call directly on any function. Example: ... Creates a callback that passes arguments[0], arguments[1], arguments[2], ...
+Call directly on any function. Example: myFunction.createCallback(arg1, arg2)
+Will create a function that is bound to those 2 args. If a specific scope is required in the
+callback, use createDelegate instead. The function returned by createCallback always
+executes in the window scope.
+ This method is required when you want to pass arguments to a callback function. If no arguments
+are needed, you can simply pass a reference to the function as a callback (e.g., callback: myFn).
+However, if you tried to pass a function with arguments (e.g., callback: myFn(arg1, arg2)) the function
+would simply execute immediately when the code is parsed. Example usage:
+ var sayHi = function(name){
+ alert('Hi, ' + name);
+}
+
+// clicking the button alerts "Hi, Fred"
+new Ext.Button({
+ text: 'Say Hi',
+ renderTo: Ext.getBody(),
+ handler: sayHi.createCallback('Fred')
+});
| Function | | createDelegate( [Object scope ], [Array args ], [Boolean/Number appendArgs ] )
:
- FunctionCreates a delegate (callback) that sets the scope to obj.
-Call directly on any function. Example: this.myFunction.cr... Creates a delegate (callback) that sets the scope to obj.
-Call directly on any function. Example: this.myFunction.createDelegate(this, [arg1, arg2])
-Will create a function that is automatically scoped to obj so that the this variable inside the
-callback points to obj. Example usage:
- var sayHi = function(name){
- // Note this use of "this.text" here. This function expects to
- // execute within a scope that contains a text property. In this
- // example, the "this" variable is pointing to the btn object that
- // was passed in createDelegate below.
- alert('Hi, ' + name + '. You clicked the "' + this.text + '" button.');
-}
-
-var btn = new Ext.Button({
- text: 'Say Hi',
- renderTo: Ext.getBody()
-});
-
-// This callback will execute in the scope of the
-// button instance. Clicking the button alerts
-// "Hi, Fred. You clicked the "Say Hi" button."
-btn.on('click', sayHi.createDelegate(btn, ['Fred']));
| Function | | createInterceptor( Function fcn , [Object scope ] )
:
- FunctionCreates an interceptor function. The passed fcn is called before the original one. If it returns false,
-the original... Creates an interceptor function. The passed fcn is called before the original one. If it returns false,
-the original one is not called. The resulting function returns the results of the original function.
-The passed fcn is called with the parameters of the original function. Example usage:
- var sayHi = function(name){
- alert('Hi, ' + name);
-}
-
-sayHi('Fred'); // alerts "Hi, Fred"
-
-// create a new function that validates input without
-// directly modifying the original function:
-var sayHiToFriend = sayHi.createInterceptor(function(name){
- return name == 'Brian';
-});
-
-sayHiToFriend('Fred'); // no alert
-sayHiToFriend('Brian'); // alerts "Hi, Brian"
| Function | | createSequence( Function fcn , [Object scope ] )
+ FunctionCreates an interceptor function. The passed function is called before the original one. If it returns false,
+the orig... Creates an interceptor function. The passed function is called before the original one. If it returns false,
+the original one is not called. The resulting function returns the results of the original function.
+The passed function is called with the parameters of the original function. Example usage:
+ var sayHi = function(name){
+ alert('Hi, ' + name);
+}
+
+sayHi('Fred'); // alerts "Hi, Fred"
+
+// create a new function that validates input without
+// directly modifying the original function:
+var sayHiToFriend = sayHi.createInterceptor(function(name){
+ return name == 'Brian';
+});
+
+sayHiToFriend('Fred'); // no alert
+sayHiToFriend('Brian'); // alerts "Hi, Brian"
Parameters:fcn : FunctionThe function to call before the original scope : Object(optional) The scope (this reference) in which the passed function is executed.
+If omitted, defaults to the scope in which the original function is called or the browser window. Returns: | Function | | createSequence( Function fcn , [Object scope ] )
:
FunctionCreate a combined function call sequence of the original function + the passed function.
The resulting function retur... Create a combined function call sequence of the original function + the passed function.
@@ -78,23 +80,25 @@ sayHi( 'Fred'); // alerts "Hi, Fred"
alert( 'Bye, ' + name);
});
-sayGoodbye( 'Fred'); // both alerts show | Function | | defer( Number millis , [Object obj ], [Array args ], [Boolean/Number appendArgs ] )
+sayGoodbye('Fred'); // both alerts show | Function | | defer( Number millis , [Object scope ], [Array args ], [Boolean/Number appendArgs ] )
:
- NumberCalls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
-var sa... Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
- var sayHi = function(name){
- alert('Hi, ' + name);
-}
-
-// executes immediately:
-sayHi('Fred');
-
-// executes after 2 seconds:
-sayHi.defer(2000, this, ['Fred']);
-
-// this syntax is sometimes useful for deferring
-// execution of an anonymous function:
-(function(){
- alert('Anonymous');
-}).defer(100);
Parameters:millis : NumberThe number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately) obj : Object(optional) The object for which the scope is set args : Array(optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller) appendArgs : Boolean/Number(optional) if True args are appended to call args instead of overriding,
+ Number Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
+var say... Calls this function after the number of millseconds specified, optionally in a specific scope. Example usage:
+ var sayHi = function(name){
+ alert('Hi, ' + name);
+}
+
+// executes immediately:
+sayHi('Fred');
+
+// executes after 2 seconds:
+sayHi.defer(2000, this, ['Fred']);
+
+// this syntax is sometimes useful for deferring
+// execution of an anonymous function:
+(function(){
+ alert('Anonymous');
+}).defer(100);
Parameters:millis : NumberThe number of milliseconds for the setTimeout call (if less than or equal to 0 the function is executed immediately) scope : Object(optional) The scope (this reference) in which the function is executed.
+If omitted, defaults to the browser window. args : Array(optional) Overrides arguments for the call. (Defaults to the arguments passed by the caller) appendArgs : Boolean/Number(optional) if True args are appended to call args instead of overriding,
if a number the args are inserted at the specified position Returns:
| Function |
Public EventsThis class has no public events.
\ No newline at end of file
|