2011-07-19 10 views
0

実行の準備メソッド呼び出し(prepared =すべてのパラメータが既に設定されている)を遅延させたいと思います。例:だから実行のためのメソッド呼び出しの準備

var storedRequest = null; 
function doAjaxRequest() { 
    //if there is no request at this moment, do the request 
    //otherwise: store the request and do nothing 

} 
//will be executed after a request is done 
function callbackAjaxRequestComplete() { 
    //is storedRequest != null --> Execute that request (the last one) 
} 

、実行準備メソッド呼び出しを格納するためのpossiblityがある:

は、私は次のリスナーメソッドを持つテキストフィールドがありますか?

答えて

3

あなたはこのような何か行うことができます。

var preparedOperation = function() { 
    return actualOperation(param1, param2, param3); 
}; 

次に「preparedOperation」にいつでも呼び出しが実際の関数への呼び出しになりますが。

Functional.jsライブラリには、この種の面白いサポートコードがあります。

+0

Functional.jsする代わりに、[underscore.js(http://documentcloud.github.com/underscore/)糖、おかげで – Raynos