假设您的意思是它在SendIdleSignal中有效,而在SendActiveSignal中无效。。。
您的事件侦听器也应该使用bind,如下所示:
Event.observe(document, "mousemove", this.sendActiveSignal.bind(this));
Event.observe(document, "keypress", this.sendActiveSignal.bind(this));
此外,如果您使用prototype 1.6或更高版本,则可以使用
document.observe("mousemove", this.sendActiveSignal.bind(this));
document.observe("keypress", this.sendActiveSignal.bind(this));
sendActiveSignal: function() {
var that = this;
return function() {
that.handlers.each(function(r) {
r.setActive();
});
}
}
然后事件处理程序/setInterval可以保留为
Event.observe(document, "keypress", this.sendActiveSignal);