Hey again,
[EMAIL PROTECTED] a écrit :
> <a href="#" onclick="Effect.toggle('d3','appear'); return
> false;">Toggle appear</a>
BTW, this code is, well... 'could be better, I guess, is a nice way to
qualify it. First, the "return false" thing is dead. Dead, dead, dead.
Second, you shouldn't put JS events in your HTML like that; you should
use unobstrusive JS.
For instance, you should assign this link an ID, then observe it from an
external script file, with something such as:
function toggleLink(e) {
Event.stop(e);
Effect.toggle('d3', 'appear', { duration: 0.5 });
} // toggleLink
Event.observe('yourLinkId', 'click', toggleLink);
If you wish to reuse the toggleLink function on multiple links, for
multiple DIVs, you can:
function toggleLink(e, containerId) {
Event.stop(e);
Effect.toggle(containerId, 'appear', { duration: 0.5 });
}
Event.observe('yourLinkId', 'click',
toggleLink.bindAsEventListener('d3');
...
--
Christophe Porteneuve aka TDD
[EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs
-~----------~----~----~----~------~----~------~--~---