Dynamic content without periodically_call_remote

I want to display a message from a list of messages and have it change to the next message every 10 seconds.

I have achieved this by putting the following javascript into my rhtml file...

<div id='dynamic_message'></div> <script type="text/javascript">   var messages=["Message One", "Message Two", "Message Three"]   var message=0;   new PeriodicalExecuter(function() {$("dynamic_message").innerHTML = messages[message++%messages.length];}, 10); </script>

Is there a railsy way of achieving the same thing?

The only thing I could find was periodically_call_remote which I didn't want to use because it would need to contact the server for every update which isn't efficient.

reed wrote:

The only thing I could find was periodically_call_remote which I didn't want to use because it would need to contact the server for every update which isn't efficient.

If you don't pass an :url into periodically_call_remote, it won't hit a server, and it will call your function from (at least) the :with argument:

  periodically_call_remote( :frequency => 1,                             :with => 'function("argument")' )