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

Re: [ydn-javascript] Re: YUI 2.2.0 menu

Expand Messages
  • Todd Kloots
    Locutus of Borg - If you want to show or hide a menu item, rather then add and remove you can just toggle the item s CSS display property:
    Message 1 of 13 , Feb 28, 2007
    • 0 Attachment
      Locutus of Borg -

      If you want to show or hide a menu item, rather then add and remove you can just toggle the item's CSS "display" property:

      oYourMenu.getItem(0).element.style.display = "none";
      oYourMenu.getItem(0).element.style.display = "block";

      Got it?

      - Todd

      ----- Original Message ----
      From: Locutus of Borg <pascal@...>
      To: ydn-javascript@yahoogroups.com
      Sent: Wednesday, February 28, 2007 5:52:11 AM
      Subject: [ydn-javascript] Re: YUI 2.2.0 menu

      Todd:
      I have a similar problem with 2.2. What I do is to use removeItem and
      InsertItem to dynamically hide/show MenuBarItems in a MenuBar.
      I initialize all my MenuBarItem on load want to keep them in memory to
      avoid having to recreate each time I need them. I therefore do not
      want to clear the content of the MenuBarItem, simple remove them from
      the MenuBar. removeItem and insertItem used to work fine but it breaks
      down in 2.2 (looks like the problem comes from events management). Any
      suggestion? Is there a way to dynamically hide/show (instead of
      remove/insert)
      many thanks
      *P

      Code example:
      ODaF.dextris.oMenuBar.removeItem(1)
      and
      ODaF.dextris.oMenuBar.insertItem(ODaF.dextris.oMenuBarItem.ddi,1);


      --- In ydn-javascript@yahoogroups.com, Todd Kloots <kloots@...> wrote:
      >
      > "digeomel" -
      >
      > You can narrow the scope of what is cleared by the
      > "clearContent" method, by calling it on a submenu or
      > set of submenus if that is all that you need. If you
      > need to just remove a single item, do so by via the
      > "removeItem" method.
      >
      > - Todd
      >
      > --- digeomel <digeomel@...> wrote:
      >
      > > The clearContent() function is a nice addition, but
      > > it applies to the
      > > whole menu.
      > > If you have a menu with lots of menu items, do you
      > > think it is more
      > > efficient to clear the whole menu and rebuild it
      > > from scratch every time
      > > rather than making surgical operations on specific
      > > menu items (as I've
      > > been doing up until now with the previous version of
      > > YUI)?
      > >
      > > It seems to me that the clearContent() function
      > > should be a method of
      > > MenuItem, not Menu.
      > >
      > >
      > > --- In ydn-javascript@yahoogroups.com, Todd Kloots
      > > <kloots@> wrote:
      > > >
      > > > "digeomel" -
      > > >
      > > > You may find it easier to use the new
      > > "clearContent" method of Menu
      > > rather than whatever custom code you've written for
      > > the job. Here is an
      > > example of it in use (if you haven't already checked
      > > it out):
      > > >
      > > >
      > >
      > http://developer.yahoo.com/yui/examples/menu/tablecontextmenu.html
      > > >
      > > > - Todd
      > > >
      > > > ----- Original Message ----
      > > > From: digeomel digeomel@
      > > > To: ydn-javascript@yahoogroups.com
      > > > Sent: Wednesday, February 21, 2007 7:56:40 AM
      > > > Subject: [ydn-javascript] Re: YUI 2.2.0 menu
      > > >
      > > >
      > > >
      > > >
      > > > Actually I just realized that some of the
      > > functionality is broken in
      > > Firefox too.
      > > > So, I'm posting the related code to help identify
      > > the problem.
      > > >
      > > > I have a function like this, used to destroy a
      > > menu item which may be
      > > a submenu:
      > > >
      > > > function destroySubmenu(i)
      > > > {
      > > > var mnuMenuItem = myContextMenu.removeItem(i);
      > > > if(mnuMenuItem)
      > > > {
      > > > var mnuSubmenu =
      > > mnuMenuItem.cfg.getProperty("submenu");
      > > > if(mnuSubmenu)
      > > > mnuSubmenu.destroy();
      > > > mnuMenuItem.destroy();
      > > > }
      > > > }
      > > >
      > > > So, I use it in my code as such:
      > > >
      > > > var menus = [[1, "Action 1", "mnuAction1",
      > > fnAction1],
      > > > !
      > > > [2, "Action 2", "mnuAction2",
      > > fnAction2],
      > > > [3, "Action 3", "mnuAction3",
      > > fnAction3]];
      > > > for(var i = 0; i < menus.length; i++)
      > > > {
      > > > destroySubmenu(menus[i][0]);
      > > > var mnuAction =
      > > myContextMenu.insertItem(menus[i][1],
      > > menus[i][0]);
      > > > mnuAction.clickEvent.subscribe(menus[i][3]);
      > > > mnuAction.CSS_CLASS_NAME = "yuimenuitem";
      > > >
      > > > mnuAction.element.id = menus[i][2];
      > > > }
      > > >
      > > > Apparently something is wrong with this code in
      > > 2.2.0....
      > > >
      > >
      > >
      >






      Yahoo! Groups Links
    Your message has been successfully submitted and would be delivered to recipients shortly.