How to create RJS visual effects callbacks

Here’s a link to a plugin I patched together a while back.

https://opensvn.csie.org/traccgi/rjscallback/trac.cgi/

Don’t get too attached to that URL, I’m trying to move it to rubyforge.

This plugin lets you specify RJS templates to be used for each of the
various remote_function callbacks.

For example,

controller/view/action_before.rjs will be loaded and used for the
‘before’ callback for any remote_function that calls
‘controller/action’.

If you use the same ones a lot, you can put them into the ‘view/shared’
folder.

It really is not well tested, and it can be inefficient if you have a
lot of remote_function calls on a page, but it works.

On Friday, April 07, 2006, at 12:25 PM, Jonathan V. wrote:

-Jonathan.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

_Kevin

Pretty much all Prototype does is execute all the generated javascript
in
another thread. Out of the box, Scriptaculous visual effects run
asynchronously, so to keep things executing in order you need to add a
page.delay after any page.visual_effect call.

page.delay simply puts the javascript generated from the block inside a
setTimeout to be run at a later stage.

Off the top of my head you’ll end up with javascript something like:

new Effect.Fade(‘comment_error’, {duration: 0.5});
setTimeout(function(){
Element.update(‘comment_error’, ‘’);
new Effect.Appear(‘comment_error’, {duration: 0.5});
}, 500);

-Jonathan.

On 7 Apr 2006 00:24:21 -0000, Kevin O. <

Works now with edgerails. A couple of points that need clarification.

You are going to need to use the page.delay function anyway.

If you set up a ‘action_before.rjs’ file like this…

page.visual_effect :slide_up, ‘testdiv’

and a regular RJS template like this…

page.replace_html ‘testdiv’,‘I’m done!’
page.visual_effect :slide_down, ‘testdiv’

You can still get things out of sync if the server responds fast enough.

Since you know how long the visual effect will last, simply modify the
second template to…

page.delay(1) do
page.replace_html ‘testdiv’,‘I’m done!’
page.visual_effect :slide_down, ‘testdiv’
end

Worst case scenario would be that there would be a short delay between
the first and second effects due to the server response time. If this
is really a problem, that means your server is really slow and you have
other problems to worry about.

On Friday, April 07, 2006, at 1:55 AM, Kevin O. wrote:

This plugin lets you specify RJS templates to be used for each of the
It really is not well tested, and it can be inefficient if you have a

end

_Kevin


Posted with http://DevLists.com. Sign up and save your mailbox.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

_Kevin

Except it doesn’t work right now. Need to make sure it’s 1.1.1
compatible.

On Friday, April 07, 2006, at 1:18 AM, Kevin O. wrote:

On Friday, April 07, 2006, at 12:25 PM, Jonathan V. wrote:

-Jonathan.


Posted with http://DevLists.com. Sign up and save your mailbox.


Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails

_Kevin

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs