YUI の .on("click", ) を使用して関数に引数を渡すことは可能ですか? たとえば、ここに私が見ているいくつかのコードがあります:
function foo1() {
var curObj = this;
this.foo2 = function() {
curObj.test = "foo2";
}
this.foo3 = function() {
curObj.test = "foo3";
}
// called by
this.blah = {};
var blah = this.blah;
blah['x'] = new YAHOO.widget.Button(x)
blah['x'].on("click", foo2)
blah['y'] = new YAHOO.widget.Button(y)
blah['y'].on("click", foo3)
}
次のようなことをして、冗長性を取り除きたいと思います。
function setTest(this, foo) {
this.test = foo;
}
function foo1() {
var curObj = this;
// called by
this.blah = {};
var blah = this.blah;
blah['x'] = new YAHOO.widget.Button(x);
blah['x'].on("click", thisTest("foo2"));
blah['y'] = new YAHOO.widget.Button(y);
blah['y'].on("click", thisTest("foo3"));
}
YUI が "this" オブジェクトを .on("click", function) から呼び出された関数に渡すことは、私の理解です。
ご協力いただきありがとうございます。