toggle appear starts hidden ?

This definitely works:

<%= button_to_remote "Test", :complete => visual_effect( :toggle_appear, "toggle_appear" ) %> <div id="toggle_appear"> yada yada yada </div>

To toggle content off -> content on, etc.

But is there any way to have the initial content hidden?

Many TIA, Craig

try

yada yada yada

Thanks, Yong!

One other question: is it possible to have multiple divs toggling on/ off at the same time? I tried changing "id" to "class", and then it simply wouldn't toggle.

Many TIA again, Craig

i never tried that, but i think you could iterate the elements with the class name like:

$$(‘.clazz’).each(function(e) {

e.toggle();

})

or else, you could write your own function, for example:

function toggle_all() {

toggle1();

toggle2();

}

function toggle1() {

}

function toggle2() {

}

...

Thanks--I was hoping that I could chain the events within/around the visual_effect method--any idea if that's possible in this framework?

Many TIA again, Craig

yes, of course

try <%= button_to_remote “Test”, :complete => “toggle_all();” %>

which toggle_all is your own defined javascript funciton or use $(‘.clazz’).each(function(e) { e.toggle()} ) directly instead of toggle_all()

in fact, the value of parameter :complete is a javascript function , and visual_effect generate a function by using prototype.js. So you could

use any javascript function as you wish.

...

Thanks! I discovered this morning that + is defined for complete, so that

<%= button_to_remote "Test", :complete => visual_effect( :toggle_appear, "toggle_appear" ) + visual_effect( :toggle_appear, "toggle_appear2" ) %>

works, which is pretty cool. It's arguably less elegant than your solution, but it keeps it purely railsy :slight_smile:

Again, many thanks!