|
| createCallback()
:
Function
配列に指定された関数をコールバック関数として登録します。ハンドラの関数に引数を設定したい場合など... Creates a callback that passes arguments[0], arguments[1], arguments[2], ... Call directly on an...
配列に指定された関数をコールバック関数として登録します。ハンドラの関数に引数を設定したい場合などに使用します。
ハンドラ内に記述する場合、「関数名.createCallback('引数')」の形で使用します。
createCallbackには、スコープの指定がありません。
スコープの指定が必要な場合は createDelegateを使用してください。
使用方法:
var sayHi = function(name){
alert('Hi, ' + name);
}
// ボタンをクリックすると次のアラートを表示します。"Hi, Fred"
new Ext.Button({
text: 'Say Hi',
renderTo: Ext.getBody(),
handler: sayHi.createCallback('Fred')
});
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 新たに生成されたFunction The new function
| Function |
| createDelegate(
[Object obj], [Array args], [Boolean/Number appendArgs]
)
:
Function配列に指定された関数をコールバック関数として登録します。createCallbackと違い、スコープが指定でき... Creates a delegate (callback) that sets the scope to obj. Call directly on any function. Example... 配列に指定された関数をコールバック関数として登録します。createCallbackと違い、スコープが指定できます。
また、第3引数の指定を行うことで、コールバック関数の引数を変更することができます。
使用方法:
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']));
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']));
パラメータ: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(オプション)true: 第2引数で指定した引数を、コールバック関数にデフォルトで渡される引数の後ろに追加。
false: 第2引数を配列として渡す。
数値: コールバック関数の引数内に、指定した数値番目に引数を挿入(数値 == N とすると第N+1引数) (optional)if True args are appended to call args instead of overriding,
if a number the args are inserted at the specified position 戻り値:Function 新たに生成された関数 The new function
| Function |
| createInterceptor(
Function fcn, [Object scope]
)
:
Function引数に設定する関数の戻り値が、trueの場合のみ設定した関数を実行することができます。
条件によって関... Creates an interceptor function. The passed fcn is called before the original one. If it returns ... 引数に設定する関数の戻り値が、trueの場合のみ設定した関数を実行することができます。
条件によって関数を呼び出したくない場合などに使用します。
使用方法:
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"
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"
パラメータ:fcn
:
Function元の関数が実行される前に実行される関数(判定などの関数で、戻り値が真偽型) The function to call before the original scope
:
Object(オプション)呼び出されるインターセプタ関数のスコープオブジェクトを指定します。(初期値:元の関数またはwindowオブジェクト) (optional)The scope of the passed fcn (Defaults to scope of original function or window) 戻り値:Function 新たに生成された関数 The new function
| Function |
| createSequence(
Function fcn, [Object scope]
)
:
Function元の関数を呼び出した後に、任意の処理を追加して呼び出します。
使用方法:
Create a combined function call sequence of the original function + the passed function. The resu... 元の関数を呼び出した後に、任意の処理を追加して呼び出します。
使用方法:
var sayHi = function(name){
alert('Hi, ' + name);
}
sayHi('Fred'); // alerts "Hi, Fred"
var sayGoodbye = sayHi.createSequence(function(name){
alert('Bye, ' + name);
});
sayGoodbye('Fred'); // both alerts show
Create a combined function call sequence of the original function + the passed function. 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"
var sayGoodbye = sayHi.createSequence(function(name){
alert('Bye, ' + name);
});
sayGoodbye('Fred'); // both alerts show
パラメータ:戻り値:Function 新たに生成された関数 The new function
| Function |
| defer(
Number millis, [Object obj], [Array args], [Boolean/Number appendArgs]
)
:
Numberミリ秒で設定した時間後、この設定された関数を呼び出します。
使用方法:
Calls this function after the number of millseconds specified, optionally in a specific scope. Ex... ミリ秒で設定した時間後、この設定された関数を呼び出します。
使用方法:
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);
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);
パラメータ:millis
:
Number待機させる時間をミリ秒で設定(内部でsetTimeout使用)、もし0を設定した場合は、即時実行 The 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(オプション)true:すべての引数を上書き 数値:設定した場所までの引数を上書き (optional)if True args are appended to call args instead of overriding,if a number the args are inserted at the specified position 戻り値: | Function |