Jason Dely wrote:
> This seems to be what I was loooking for.
> Now what I would like to know is how can I restart the call?
> Can I push it from the server based on new data now available?
I ran into these issue myself. After much struggle and frustration, it
dawned on me that doing periodic updates with straight up JavaScript is
really pretty easy. And, I found it to be more flexible anyway.
Here is an example of my solution. This happens to be jQuery, but the
same applies to Prototype:
------------------------
var myInterval;
// Wait for DOM to load
$(document).ready(function() {
startUpdater();
// Setup start/stop buttons
$("#stop_refresh").click(stopUpdater);
$("#start_refresh").click(startUpdater);
});
function startUpdater() {
myInterval = window.setInterval(doUpdate, 2000);
}
function stopUpdater() {
window.clearInterval(myInterval);
return false;
}
function doUpdate() {
var url = "url/to/new/content";
$("#content_div").load(url);
}
------------------------
Note: this is also an Unobtrusive JavaScript solution, which is another
bonus.
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.