I’ve been reading through the forums and came across a response for
adding :with condition to a periodically call remote.
I tried it out and couldn’t make it work. Would anyone have a sample of
how to use this conditional structure with periodically call remote?
If not, does anyone have any idea how to add a condition to a
periodically call remote?
What I need is to pass the values of my userid together with the
periodically call remote function so that my index controller knows that
this particular session is the one that is requesting this update from
the server.
periodically_call_remote passes the supplied options hash (minus the
:frequency option) to the remote_function method, which accepts the same
parameters as link_to_remote. so check the docs for link_to_remote for
acceptable parameters and usage. from the docs, :conditions =>
“javascript
code” would be what you want.
an example that i would imagine would work (untested):
this says to call the remote url of /mycontroller/myaction/123 every 10
seconds and update the DOM element with id = ‘results’ ONLY IF the
element
is visible
btw, session information is handled transparently by the ajax calls, so
you
don’t have to track sessions by passing information in the url.
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.