( 経由で) 特定の変数に事前にバインドされたイベント ハンドラーがあります$.proxy。その結果、ハンドラーがトリガーされるとthis、通常の値ではなく、事前にバインドされた値になります。
thisハンドラーのevent引数を使用して回復したいのですが、 、、またはその他のイベント プロパティにthis直接マップされていないようです。event.currentTargetevent.target
そこで、jQuery のソースを調べてみましたが、イベント コールバックは非常に複雑で、何thisが設定されているのか正確にはわかりません。thisイベント引数のみを使用してjQueryイベントハンドラーをシミュレートする方法を知っている人はいますか?
* * 編集 * *
明確にするために、ここに例を示します。
var boundThis = {foo: 'bar'}
var handler = $.proxy(function(event) {
// Because of the $.proxy, this === boundThis
// (NOT the normal "this" that jQuery would set)
// In theory event has everything I need to re-create this,
// but I'm having trouble figuring out exactly how
// Here's a naive/non-functional example of what I'm trying to do
jQueryThis = event.target; // If only this worked ...
}, boundThis);
$(someElement).click(handler);