O'Reilly logo

MooTools 1.3 Cookbook by Jay Larry G. Johnston

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Updating a scrolling ticker periodically

Review the previous recipe; all we will be adding here is a periodic refresh that updates the data.

How to do it...

Creating a periodical object has a simple syntax that takes a mandatory first argument of how many milliseconds after which to repeat the function call.

// periodically (every 10 seconds) refresh the stock ticker
var refresh_ticker = function() { myJax.send(); };
var my_ticker_refresh = refresh_ticker.periodical(10*1000);
// delay (once after 30 seconds) stop the ticker refresh!
var stop_ticker_refresh = function(){ clearInterval(my_ticker_refresh); };
stop_ticker_refresh.delay(30*1000);

Stopping the function call requires us to have saved the result of the periodical instantiation. In our recipe, ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required