1
入れ子になったjquery.proxyを使うことはできますか?入れ子になったjquery.proxyを使うことができます
var obj = {
init: function(element){
element.on('click.mynamespace',$.proxy(function (event) {
$(event.currentTarget).animate({
scrollLeft: scrollPos
}, width, $.proxy(this.myFunction,this));
},this))
},
myFunction: function(){
/*some code*/
}
}
これは私のプロジェクトに必要なものです。私は入れ子になった$ .proxyを使ってコードを動作させました。なぜなら、jquery animate
apiのコールバック関数であるmyFunctionにthis
というコンテキストが必要だからです。 このように使用できますか?