Loading ...
Sorry, an error occurred while loading the content.

Re: Accessing individual sub menu items. (applying behaviors to menu items)

Expand Messages
  • yazdog8
    Todd, Thanks for the example. I think the leap I m not making is how to drill down to a specific submenu. if I take your example and juxtapose it to my code:
    Message 1 of 6 , Aug 29, 2007
    • 0 Attachment
      Todd,

      Thanks for the example. I think the leap I'm not making is how to
      drill down to a specific submenu.

      if I take your example and juxtapose it to my code:

      this.navMenu.mouseOverEvent.subscribe(test, this.navMenu); (because
      you are using menu while we're using menuItem)

      That gets me the event on the submenu title. I can then use your
      function, but it only gets me top level information as opposed to the
      specific item clicked in the sub menu. How do I access menuItems of
      MenuBars as opposed to Menus? There seems to be a difference I'm just
      not connecting the dots with.

      -Joe

      --- In ydn-javascript@yahoogroups.com, Todd Kloots <kloots@...> wrote:
      >
      > Joe -
      >
      > The YUI Menu widget uses event bubbling by default and provides a
      > CustomEvent-based interface for listening for DOM events. You can
      add a
      > listener for a given event via the "subscribe" method. For example:
      >
      > oMenu.subscribe("click", onMenuClick);
      >
      > As noted on the YUI Menu landing page, you should always use the
      > provided Custom Event-based interface rather than attaching handlers
      > directly to a Menu's DOM elements via the addListener method as you are
      > currently doing.
      >
      > When you subscribe to an event, the listener will automatically be
      > subscribed to all submenus as they are created. So there is no need to
      > worry about submenus being lazy loaded.
      >
      > I created an example for you:
      >
      > http://yuiblog.com/sandbox/yui/v230/examples/menu/example02.html
      >
      >
      > Be sure to let me know if you have any more questions and good luck
      with
      > your project.
      >
      > - Todd
      >
      >
      > Caridy Patiño Mayea wrote:
      > >
      > > Hi Joe:
      > >
      > > There is several ways to add a behavior to a certain menu item, but
      > > there is a lot of factors that you need to keep in mind, specially for
      > > lazy menus (addListener on render, purgeElement on destroy,
      > > stopPropagation, etc).
      > >
      > > But there is a very simple way, (I use it all the time), using the
      > > bubbling technique.
      > >
      > > I wrote an example for you, take a look:
      > > http://www.bubbling-library.com/sandbox/menus/easy-item-behavior.html
      > >
      <http://www.bubbling-library.com/sandbox/menus/easy-item-behavior.html>
      > >
      > > Best Regards,
      > > Caridy (caridy at gmail.com)
      > > http://www.bubbling-library.com/ <http://www.bubbling-library.com/>
      > >
      > > --- In ydn-javascript@yahoogroups.com
      > > <mailto:ydn-javascript%40yahoogroups.com>, "yazdog8" <yazdog8@> wrote:
      > > >
      > > > I'm currently working on a unique problem with our implementation of
      > > > the YUI menu. It can be viewed here:
      > > >
      > > > http://jpaulsen.dev.gaiaonline.com/mygaia/
      > > <http://jpaulsen.dev.gaiaonline.com/mygaia/>
      > > >
      > > > Login is not necessary.
      > > >
      > > > There are several menu items (look under games) that actually
      launch a
      > > > pop-up flash window. I used the Dom addListener to attach events to
      > > > the A via ID, but this does not launch a window, it forwards the
      user
      > > > on to the flash in the same browser.
      > > >
      > > > I've been looking at the documentation, and I can't see how to
      access
      > > > individual sub menu items to I can turn off the custom event and
      add a
      > > > specific click event of my own.
      > > >
      > > > I've gotten as far as:
      > > > this.navMenu.getItem(x).cfg.getProperty("submenu"), where X
      equals the
      > > > number of the submenu I want to access. How do I get specific items
      > > > within that sub menu?
      > > >
      > > > Thanks!
      > > >
      > > > -Joe
      > > >
      > >
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.