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

Re: Having problem with Menu.insertItem ()

Expand Messages
  • russncraig
    Ah, apparently i was still using 0.11.1. I m embarassed to have missed that. Have updated to 0.11.3 and it works just fine -- and as a bonus the menu now
    Message 1 of 3 , Nov 1, 2006
    • 0 Attachment
      Ah, apparently i was still using 0.11.1. I'm embarassed to have
      missed that. Have updated to 0.11.3 and it works just fine -- and as
      a bonus the menu now closes automatically on click!

      Thanks, as always, for your help.

      russ

      --- In ydn-javascript@yahoogroups.com, Todd Kloots <kloots@...> wrote:
      >
      > Russ -
      >
      > Your example worked for me. Here is my test page:
      >
      > http://yuiblog.com/sandbox/yui/v0114/examples/menu/example06.php
      >
      >
      > What version of YUI are you using? Are you seeing
      > this problem in a specific browser or is it consistent
      > across all of our supported browsers?
      >
      > - Todd
      >
      > --- russncraig <russ@...> wrote:
      >
      > > I am trying to insert a dynamically created menu
      > > item at the top of an
      > > existing menu with insertItem(). I think i have
      > > verified that the item
      > > is successfully added to the items array
      > > (_aItemGroups[i]), but the
      > > item's DOM element isn't added to the menu group's
      > > UL element
      > > (represented in _aListElements[i]). I'm totally
      > > perplexed.
      > >
      > > Here's a very simple example of what i'm trying to
      > > accomplish.
      > > addItem() works just fine, but insertItem() appears
      > > to have no effect.
      > >
      > > function initMenu () {
      > >
      > > var addItemToTop = function (e) {
      > > var time = new Date().getTime().toString();
      > > menu.insertItem (new YAHOO.widget.MenuItem (time),
      > > 0);
      > > }
      > > var addItemToBottom = function (e) {
      > > var time = new Date().getTime().toString();
      > > menu.addItem (new YAHOO.widget.MenuItem (time));
      > > }
      > >
      > > var menu = new YAHOO.widget.Menu ("menu", {
      > > zIndex:2 });
      > > var insert = menu.addItem (new
      > > YAHOO.widget.MenuItem ("Add an item at
      > > top of this menu"));
      > > YAHOO.util.Event.addListener (insert.element,
      > > "click", addItemToTop);
      > > var add = menu.addItem (new YAHOO.widget.MenuItem
      > > ("Add an item at
      > > bottom of this menu"));
      > > YAHOO.util.Event.addListener (add.element, "click",
      > > addItemToBottom);
      > > menu.render (document.body);
      > > menu.show();
      > >
      > > }
      > > YAHOO.util.Event.addListener (window, "load",
      > > initMenu);
      > >
      > >
      > > russ
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > >
      > > Yahoo! Groups Links
      > >
      > > (Yahoo! ID required)
      > >
      > > mailto:ydn-javascript-fullfeatured@yahoogroups.com
      > >
      > >
      > >
      > >
      > >
      > >
      >
    Your message has been successfully submitted and would be delivered to recipients shortly.