0
クラス機能をmootoolsで定期的に実行するのに問題があります。それは1つの罰金を実行しますが、私は関数が定義されていないエラーを取得します。関連するコードは次のとおりです。http://gist.github.com/142298Mootools定期的な問題
クラス機能をmootoolsで定期的に実行するのに問題があります。それは1つの罰金を実行しますが、私は関数が定義されていないエラーを取得します。関連するコードは次のとおりです。http://gist.github.com/142298Mootools定期的な問題
正しく機能していないのは、MooTools documentationです。あなたの例では
、あなたは一度関数を実行し、(それゆえ、あなたの最初のメッセージが1000msでは遅らせない後、直接記録されます)、それの戻り値に定期的な機能を使用しよう:
var Main = new Class({
Implements: [Options],
options: {
releaseDate: '1 January, 2010'
},
initialize: function(options){
this.setOptions(options);
this.startClock();
},
startClock: function(){
var current = $time();
var future = new Date(this.options.releaseDate);
future = future.getTime();
this.clock = this.iterateClock(current, future).periodical(1000, this);
},
iterateClock: function(current, future){
var difference = future - current;
var days = Math.floor((difference/(60 * 60 * 24))/1000);
console.log(days);
}
});
あなたが欲しいです指定された期間、バインディングと引数(配列として)を指定してiterateClock関数を定期的に呼び出します。
this.clock = this.iterateClock.periodical(1000, this, [current, future]);
mootoolsのメールリストで同じ回答を得ました。これを解決する別の方法は、anon関数をクロージャとして使用し、元のコードと同じように定期的に適用することです。 –