开发者

Delayed start of Ajax.PeriodicalUpdater

In my web-app have a statusbar for my users where number of new messages etc is shown. I use Ajax.PeriodicalUpdater for refreshing every 60 sec. But the PeriodicalUpdater is doing the first fetch on initialization when there is no need as the data is fresh on page load.

So what is your best practice to st开发者_JAVA技巧art the Updater 60 seconds after page load?

I am using a window.setTimeout to call a function that starts the updater, but is there something better?

function statusbarUpdate(){
  new Ajax.PeriodicalUpdater({
    success: 'statusbar'
  }, '/status', {
    method: 'get',
    frequency: 60,
    decay: 1
  });
}
window.setTimeout("statusbarUpdate()", 1000 * 60)


There is nothing in Ajax.PeriodicalUpdater's source that allows for a delayed start.

However for a bit of syntactic sugar the last line can be neatened:

statusbarUpdate.delay(1000 * 60);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜