Rails Order of Execution


I have an RJS file that has scriptaculous page calls and system()
function calls. They’re in the order of system(), scriptaculous,
system(), system(), scriptaculous. It seems that all the system()
functions get executed first, then the scriptaculous effects. Is there
anyway to have my code get executed in the original order? For example,
the first system call stops a recording, and first scriptaculous call
displays a “saving”

tag; the other two system() tag saves the
recording, and the final scriptaculous call displays a “recording

Any help is appreciated

The scriptaculous calls merely generate JavaScript that will eventually
sent to the client. Your RJS file is executed and rendered by the
all your system() calls will happen now, and the JavaScript required to
produce the effects on the frontend will have been generated – not
executed. The generated code is then sent to the client (your browser)
it is then executed and you see the fancy effects.

You’ll need to perform some ajax calls from the frontend that respond
RJS to trigger the system() calls on the server. You’ll need one ajax
per system() call (unless you group them up) which will obviously take
a while with any more just a couple of remote calls. Not to mention that
you’ll need to keep and eye out for clients that don’t perform the full
number of requests that you’d expect.

My advice is to keep your design as simple as possible, it sounds like
you’re going to end up with a lot of complex code just for the benefit
having effects fire in “real” time.