Dudebot
(Dudebot)
March 29, 2010, 6:05am
1
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
Dudebot
(Dudebot)
March 29, 2010, 6:15am
3
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
Yong_Gu
(Yong Gu)
March 29, 2010, 6:24am
4
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() {
…
}
Dudebot
(Dudebot)
March 29, 2010, 6:40am
5
...
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
Yong_Gu
(Yong Gu)
March 29, 2010, 6:49am
6
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.
Dudebot
(Dudebot)
March 29, 2010, 2:05pm
7
...
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
Again, many thanks!