12/01/30 18:12:44.99 QZ0U/9Kn
★の部分のthisがBBS内のthisじゃなくてクリックされた要素になるんだけど
clickのイベントハンドラを匿名じゃないメソッドとして定義しつつ
thisをBBSと同じスコープのthisとして使う方法はない?
var BBS = function() {
this.messages = new Array();
this.box = $("#box");
this.button = $("#button");
}
BBS.prototype.show = function() {
for(var i = 0; i < this.messages.length; ++i) {
this.box.append(this.messages[i]);
}
this.button.onclick(this.post);
}
BBS.prototype.post = function(ev) {
var message = getMessage();
this.messages.push(message); # ←★
}