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

Re: Dynamically adding groups and submenus to a menu

Expand Messages
  • platformconnolly
    I ve been working away on this since my original message and haven t made any progress. Does anyone have any suggestions or pointers to resources? Mark
    Message 1 of 3 , Oct 31, 2007
      I've been working away on this since my original message and haven't
      made any progress. Does anyone have any suggestions or pointers to
      resources?

      Mark

      --- In ydn-javascript@yahoogroups.com, "platformconnolly"
      <connolly@...> wrote:
      >
      > Can anyone tell me how to dynamically add, and remove, groups and
      > submenus to a context menu? I seem to be able to add items (one at a
      > time and in multiples), but have not been able to figure out how to
      > add groups or submenus.
      >
      > Is it possible to simply set the itemdata property with an appropriate
      > array that represents the desired new menu structure? That would be
      > ideal for my purposes, but I can't seem to make that work.
      >
      > Thanks,
      > Mark
      >
    • Todd Kloots
      Mark - You can add a submenu to any item on the fly via use of the submenu configuration property. Several of the Menu examples add submenus dynamically,
      Message 2 of 3 , Nov 7, 2007
        Mark -

        You can add a submenu to any item on the fly via use of the "submenu"
        configuration property. Several of the Menu examples add submenus
        dynamically, for example:

        http://developer.yahoo.com/yui/examples/menu/leftnavfromjs.html
        http://developer.yahoo.com/yui/examples/menu/topnavfromjs.html


        To remove a submenu from an item, simply call the submenu's "destroy"
        method. For example:

        oMenu.getItem(0).cfg.getProperty("submenu").destroy();


        You can add groups on the fly by specifying a group number when calling
        the addItem, addItems, or insertItem methods. For example:

        var oMenu = new YAHOO.widget.Menu("test");

        oMenu.addItem("test");

        oMenu.addItems(["one", "two", "three"], 1);

        oMenu.render(document.body);

        oMenu.show();

        - Todd

        platformconnolly wrote:
        >
        > I've been working away on this since my original message and haven't
        > made any progress. Does anyone have any suggestions or pointers to
        > resources?
        >
        > Mark
        >
        > --- In ydn-javascript@yahoogroups.com
        > <mailto:ydn-javascript%40yahoogroups.com>, "platformconnolly"
        > <connolly@...> wrote:
        > >
        > > Can anyone tell me how to dynamically add, and remove, groups and
        > > submenus to a context menu? I seem to be able to add items (one at a
        > > time and in multiples), but have not been able to figure out how to
        > > add groups or submenus.
        > >
        > > Is it possible to simply set the itemdata property with an appropriate
        > > array that represents the desired new menu structure? That would be
        > > ideal for my purposes, but I can't seem to make that work.
        > >
        > > Thanks,
        > > Mark
        > >
        >
        >
      Your message has been successfully submitted and would be delivered to recipients shortly.