私の問題は、長方形の複数のイベントを処理する必要があることです。それは単純に聞こえます、例えばこれはうまくいきます
node.click(function(e){
click(); // this is function defined in same scope, it works ok
});
node.mouseout(function(e){
mouseout();
});
しかし、これを自動化したいので、次のようになります。
var events = new Array("click", "mouseout");
for(var i in events){
node[events[i]](function(e){
events[i](); /*THIS is problem, no matter if it is click or mouseout
this always fires function with same name as last item
in events array (in this case mouseout)
*/
}
}
なぜ私がそれを解決する必要があるのか、あなたは何か考えがありますか?