Actually the observer is not attached to sub1 and sub2 - but the event from
those elements is bubbling up to the parent <li> and the event is firing.
try this - instead of attaching to the <li> parent try attaching to the <a
href> and add an ID attribute to it
snip...
<li><a href="#" id="helpink"><span>Help</span></a>
<ul>
<li><a href="#" role="menuitem"><span>sub1</span></a></li>
<li><a href="#" role="menuitem"><span>sub2</span></a></li>
</ul>
</li>
snip...
then the javascript becomes
$('helplink').observe("mouseover",respondTo);
if you have multiple helplinks you can turn it into a class like so
<li><a href="#" class="helpink"><span>Help</span></a>
<ul>
<li><a href="#" role="menuitem"><span>sub1</span></a></li>
<li><a href="#" role="menuitem"><span>sub2</span></a></li>
</ul>
</li>
then the javascript is
$$(".helplink").invoke("observe","mouseover",respondTo);
The invoke() method will iterate over the array that is returned and do the
specified method on those items
Jason Westbrook | T: 313-799-3770 | [email protected]
On Sun, Dec 16, 2012 at 9:45 AM, Laurent Barre <[email protected]> wrote:
> Hi,
>
> I have :
>
> <nav id="navigation" role="navigation">
> <ul id="menu" role="menubar">
> <li title="Hello World!"><a href="#"><span>Home</span></a></li>
> <li attr="parent"><a href="#"><span>Help</span></a>
> <ul>
> <li><a href="#" role="menuitem"><span>sub1</span></a></li>
> <li><a href="#" role="menuitem"><span>sub2</span></a></li>
> </ul>
> </li>
> </nav>
>
>
>
> $$('[attr="parent"]').each(function (elt) {
> Event.observe(elt,'mouseover',respondTo);
> });
>
> function respondTo() {
> trace('ok');
> }
>
> My problem is that "sub1, sub2" are link to event.observe.
> I'd like to have only "help" who will link with event.observe.
>
> How do I do for separate the parent and children element ?
>
> Best regard.
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Prototype & script.aculo.us" 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/prototype-scriptaculous?hl=en.