Multiple periodically_call_remote calls not behaving as expected
I've been doing ruby and rails for a long time but am a newbie when it comes to the more dynamic elements (currently jrails and jQuery), so it's entirely possible I'm missing something.
That said, I've got a page where multiple elements need updating from multiple sources. For example, a dynamic header comes from one source and 5-6 divs of information come from the second. I've got 6-7 periodically_call_remote calls with appropriate :condition flags set so only the visible one actually results in a call. The problem is, even with none of the other divs visible, there are 7 calls to the dynamic header!
For clarity, I created a page that demonstrates similar behavior:
<%= javascript_include_tag 'jquery' %>
The server time is:
<%= render :partial => 'time' %>
<%= periodically_call_remote(:update => 'time',
:url => { :action => :time },
:frequency => 3) %>.
Here's the results from some other function!
<%= render :partial => 'count' %>
<%= periodically_call_remote(:update => 'count',
:url => { :action => :count },
:frequency => 3,
:condition => "false")
%>
I'm expecting that, every three seconds, this will call 'time' on the server and replace the old 'time' div with the new one. It'll never call 'count'.
What actually happens is that, every three seconds, it calls 'time' twice. If I include a third periodically_call_remote, it'll call it three times.
Is this a bug? A subtl开发者_C百科ety of jQuery I don't yet understand? Ancient curse? What's the deal here?
I apparently can't close my own question and I don't want to delete it lest others repeat my horrifying mistake, so I'm commenting and marking that as the answer.
The answer was: Upgrade.
精彩评论