Basically, the easiest thing to do would be to get all of the div
elements to which you wish to apply the Effect and then make them
observe the mouseover event to do so. I''m a little concerned, however,
that you might be making a bit of a mistake: you mentioned that you use
the div in many places; when you do so, do they all have an id of
video? If so, you''re probably going to have to rework things anyway as
only one element can have any given id per page (that is, only one <div
id="video"> per page). The better thing to do would be to make
them
<div class="video"> as the class attribute can be repeated as
necessary.
Then, you can do something like this:
$$("div.video").each(function(element) {
element.observe("mouseover", function(event) {
// apply your effect here
});
});
The $$() function will select all of the elements on the page which
match the CSS selector that''s passed as the parameter. In other words,
in the above snippet, it''ll get all of the <div
class="video">
elements. Then, the each() function iterates through each of those
elements performing the anonymous function. That function makes sure
that each element, each <div class="video"> observes the
mouseover event
and, when that event occurs, will execute the other anonymous function
which actually applies the event.
You''ll probably want to head to http://www.prototypejs.org/api and look
at the information about the $$ utility method, the each() function of
the Enumerable object, and the observe method of the Element object to
get the information on them from the horses mouth, so to speak.
Feel free to ask any questions you have. Many of us here are old hats
at this programming stuff and we''re always more than happy to try and
help someone learn.
- Dashifen -
Brandon wrote:> Hi,
>
> How would I place the scriptaculous functions (for example the
> effects) into a style sheet? Right now I am hardcoding them into my
> rhtml templates ( for example <div id="video"
onMouseOver="new
> Effect...."> ) But since I use that div in many places it will be
> cumbersome to change them all.
>
> I apologize in advance if my question seems elementary. I just
> started learning about web development for a class i am taking and
> have been only doing web development since february.
>
> Thanks!
>
>
> >
>
>
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---