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

YUI 2.2.0 menu

Expand Messages
  • digeomel
    Hello, I just tried upgrading my web app to 2.2.0 and I noticed that MSIE7 (haven t tried with 6 yet) complains about line 4355 in menu.js: getItems:
    Message 1 of 13 , Feb 21, 2007
    • 0 Attachment
      Hello,

      I just tried upgrading my web app to 2.2.0 and I noticed that MSIE7 (haven't tried with 6 yet) complains about line 4355 in menu.js:

      getItems: function() {
          var aGroups = this._aItemGroups,
              nGroups = aGroups.length;
          return (
                      (nGroups == 1) ? aGroups[0] :
                          (Array.prototype.concat.apply([], aGroups))
                  );
      },

      Claiming that 'length' is null or not an object.

      I have a context menu which changes dynamically, and sometimes a menu item may become a submenu (depending on the context). On Firefox it works ok. I work in HTML 4.01 strict mode.
      I went through the README file for the menu and I can't see anything that should be affected.
      Any ideas what's going on?

      BTW, the onclick config property is a great addition to the menu class! B-)

      Thanks in advance.
    • digeomel
      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
      Message 2 of 13 , Feb 21, 2007
      • 0 Attachment
        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....
      • Todd Kloots
        Can you please provide a link or code sample that demonstrates how to repro? ... From: digeomel To: ydn-javascript@yahoogroups.com Sent:
        Message 3 of 13 , Feb 21, 2007
        • 0 Attachment
          Can you please provide a link or code sample that demonstrates how to repro?

          ----- Original Message ----
          From: digeomel <digeomel@...>
          To: ydn-javascript@yahoogroups.com
          Sent: Wednesday, February 21, 2007 6:10:10 AM
          Subject: [ydn-javascript] YUI 2.2.0 menu

          Hello,

          I just tried upgrading my web app to 2.2.0 and I noticed that MSIE7 (haven't tried with 6 yet) complains about line 4355 in menu.js:

          getItems: function() {
              var aGroups = this._aItemGroups,
                  nGroups = aGroups.length;
              return (
                          (nGroups == 1) ? aGroups[0] :
                              (Array.prototype.concat.apply([], aGroups))
                      );
          },

          Claiming that 'length' is null or not an object.

          I have a context menu which changes dynamically, and sometimes a menu item may become a submenu (depending on the context). On Firefox it wo! rks ok. I work in HTML 4.01 strict mode.
          I went through the README file for the menu and I can't see anything that should be affected.
          Any ideas what's going on?

          BTW, the onclick config property is a great addition to the menu class! B-)

          Thanks in advance.

        • digeomel
          No, it would be too hard for me to reproduce it, but I ve already solved part of the problem. It seems that the line (refer to my code posted above)
          Message 4 of 13 , Feb 21, 2007
          • 0 Attachment
            No, it would be too hard for me to reproduce it, but I've already solved part of the problem.
            It seems that the line (refer to my code posted above)

            mnuItem.element.id = "myElementId";

            must now be replaced by

            mnuItem.id = "myElementId";

            And all menu items will work fine again across browsers.
            My problem is now that I can't get the icons for the menu items to show, in other words, although the <li>'s id should change with the code above, and thus show the related icon specified in the css, it doesn't. Any ideas?



            --- In ydn-javascript@yahoogroups.com, Todd Kloots <kloots@...> wrote:
            >
            > Can you please provide a link or code sample that demonstrates how to repro?
            >
            > ----- Original Message ----
            > From: digeomel digeomel@...
            > To: ydn-javascript@yahoogroups.com
            > Sent: Wednesday, February 21, 2007 6:10:10 AM
            > Subject: [ydn-javascript] YUI 2.2.0 menu
            >
            >
            >
            >
            > Hello,
            >
            > I just tried upgrading my web app to 2.2.0 and I noticed that MSIE7 (haven't tried with 6 yet) complains about line 4355 in menu.js:
            >
            > getItems: function() {
            > var aGroups = this._aItemGroups,
            > nGroups = aGroups.length;
            > return (
            > (nGroups == 1) ? aGroups[0] :
            > (Array.prototype.concat.apply([], aGroups))
            > );
            > },
            >
            > Claiming that 'length' is null or not an object.
            >
            > I have a context menu which changes dynamically, and sometimes a menu item may become a submenu (depending on the context). On Firefox it wo!
            > rks ok. I work in HTML 4.01 strict mode.
            > I went through the README file for the menu and I can't see anything that should be affected.
            > Any ideas what's going on?
            >
            > BTW, the onclick config property is a great addition to the menu class!
            >
            > Thanks in advance.
            >
          • Todd Kloots
            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
            Message 5 of 13 , Feb 21, 2007
            • 0 Attachment
              "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....

            • Todd Kloots
              You re not use the id property correctly here. You need to set the id via the MenuItem s set of configuration properties that are passed to the constructor.
              Message 6 of 13 , Feb 21, 2007
              • 0 Attachment
                You're not use the id property correctly here.  You need to set the id via the MenuItem's set of configuration properties that are passed to the constructor.  This is noted in the docs:

                http://developer.yahoo.com/yui/docs/YAHOO.widget.MenuItem.html#id

                - Todd

                ----- Original Message ----
                From: digeomel <digeomel@...>
                To: ydn-javascript@yahoogroups.com
                Sent: Wednesday, February 21, 2007 8:47:07 AM
                Subject: [ydn-javascript] Re: YUI 2.2.0 menu

                No, it would be too hard for me to reproduce it, but I've already solved part of the problem.
                It seems that the line (refer to my code posted above)

                mnuItem.element.id = "myElementId";

                must now be replaced by

                mnuItem.id = "myElementId";

                And all menu items will work fine again across browsers.
                My problem is now that I can't get the icons for the menu items to show, in other words, although the <li>'s id should change with the code above, and thus show the related icon specified in the css, it doesn't. Any ideas?



                --- In ydn-javascript@yahoogroups.com, Todd Kloots <kloots@...> wrote:
                >
                > Can you please provide a link or code sample that demonstrates how to repro?
                >
                > ----- Original Message ----
                > From: digeomel digeomel@...
                > To: ydn-javascript@yahoogroups! .com
                > Sent: Wednesday, February 21, 2007 6:10:10 AM
                > Subject: [ydn-javascript] YUI 2.2.0 menu
                >
                >
                >
                >
                > Hello,
                >
                > I just tried upgrading my web app to 2.2.0 and I noticed that MSIE7 (haven't tried with 6 yet) complains about line 4355 in menu.js:
                >
                > getItems: function() {
                > var aGroups = this._aItemGroups,
                > nGroups = aGroups.length;
                > return (
                > (nGroups == 1) ? aGroups[0] :
                > (Array.prototype.concat.apply([], aGroups))
                > );
                > },
                >
                > Claiming that 'length' is null or not an object.
                >
                > I have a context menu which changes dynamically, and sometimes a menu item may become a submenu (depending on the context). On Firefox it wo!
                > rks ok. I work in HTML 4.01 strict mode.
                > I went through the README file for the menu and I can't see anything that should be affe! cted.
                > Any ideas what's going on?
                >
                > BTW, the onc lick config property is a great addition to the menu class!
                >
                > Thanks in advance.
                >

              • digeomel
                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
                Message 7 of 13 , Feb 22, 2007
                • 0 Attachment
                  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....
                  >
                • digeomel
                  Are you refering to my old method of using id (mnu.element.id) or the last one (mnu.id)? I ve read the docs, but currently this was the only fast way to get it
                  Message 8 of 13 , Feb 22, 2007
                  • 0 Attachment
                    Are you refering to my old method of using id (mnu.element.id) or the
                    last one (mnu.id)?

                    I've read the docs, but currently this was the only fast way to get it
                    (partially) working again.

                    What if you want to change the id dynamically at runtime?


                    --- In ydn-javascript@yahoogroups.com, Todd Kloots <kloots@...> wrote:
                    >
                    > You're not use the id property correctly here. You need to set the id
                    via the MenuItem's set of configuration properties that are passed to
                    the constructor. This is noted in the docs:
                    >
                    > http://developer.yahoo.com/yui/docs/YAHOO.widget.MenuItem.html#id
                    >
                    > - Todd
                    >
                    > ----- Original Message ----
                    > From: digeomel digeomel@...
                    > To: ydn-javascript@yahoogroups.com
                    > Sent: Wednesday, February 21, 2007 8:47:07 AM
                    > Subject: [ydn-javascript] Re: YUI 2.2.0 menu
                    >
                    >
                    >
                    >
                    > No, it would be too hard for me to reproduce it, but I've already
                    solved part of the problem.
                    > It seems that the line (refer to my code posted above)
                    >
                    > mnuItem.element.id = "myElementId";
                    >
                    > must now be replaced by
                    >
                    > mnuItem.id = "myElementId";
                    >
                    > And all menu items will work fine again across browsers.
                    > My problem is now that I can't get the icons for the menu items to
                    show, in other words, although the <li>'s id should change with the code
                    above, and thus show the related icon specified in the css, it doesn't.
                    Any ideas?
                    >
                    >
                    >
                    > --- In ydn-javascript@yahoogroups.com, Todd Kloots kloots@ wrote:
                    > >
                    > > Can you please provide a link or code sample that demonstrates how
                    to repro?
                    > >
                    > > ----- Original Message ----
                    > > From: digeomel digeomel@
                    > > To: ydn-javascript@yahoogroups!
                    > .com
                    > > Sent: Wednesday, February 21, 2007 6:10:10 AM
                    > > Subject: [ydn-javascript] YUI 2.2.0 menu
                    > >
                    > >
                    > >
                    > >
                    > > Hello,
                    > >
                    > > I just tried upgrading my web app to 2.2.0 and I noticed that MSIE7
                    (haven't tried with 6 yet) complains about line 4355 in menu.js:
                    > >
                    > > getItems: function() {
                    > > var aGroups = this._aItemGroups,
                    > > nGroups = aGroups.length;
                    > > return (
                    > > (nGroups == 1) ? aGroups[0] :
                    > > (Array.prototype.concat.apply([], aGroups))
                    > > );
                    > > },
                    > >
                    > > Claiming that 'length' is null or not an object.
                    > >
                    > > I have a context menu which changes dynamically, and sometimes a
                    menu item may become a submenu (depending on the context). On Firefox it
                    wo!
                    > > rks ok. I work in HTML 4.01 strict mode.
                    > > I went through the README file for the menu and I can't see anything
                    that should be affe!
                    > cted.
                    > > Any ideas what's going on?
                    > >
                    > > BTW, the onc
                    > lick config property is a great addition to the menu class!
                    > >
                    > > Thanks in advance.
                    > >
                    >
                  • digeomel
                    Never mind, I made it all work again using clearContent() and specifying the id in the constructor, as you suggested. I still think that for large menus it is
                    Message 9 of 13 , Feb 22, 2007
                    • 0 Attachment
                      Never mind, I made it all work again using clearContent() and specifying the id in the constructor, as you suggested.

                      I still think that for large menus it is probably inneficient to rebuild the whole menu from scratch though.

                      In fact, I think I've noticed a slight delay in creating the menu again, after calling clearContent().

                      In the process, I've stumbled across something that looks like a bug (unless I'm missing something again). There seems to be a difference between writing:

                      mymenu.addItem({ text:"Action 1", id:"mnuAction1", onclick: { fn:fnAction1 }});

                      and

                      var mnuItem = mymenu.addItem({ text:"Action 1", id:"mnuAction1" });
                      mnuItem.clickEvent.subscribe(
                      fnAction1);

                      The 2nd approach works for me, but the 1st sometimes doesn't.

                      Anyway, thanks for your help! :)

                    • Todd Kloots
                      If you want to set the id of a menu item when you instantiate it, then you pass the id as one of the configuration arguments: var oMenuItem = new
                      Message 10 of 13 , Feb 22, 2007
                      • 0 Attachment
                        If you want to set the id of a menu item when you
                        instantiate it, then
                        you pass the id as one of the configuration arguments:

                        var oMenuItem = new YAHOO.widget.MenuItem("my menu
                        item", { id: "mymenuitem" });

                        Don't change the id at runtime because it will cause
                        things to break, just like if you change a Menu
                        instance's id at runtime.

                        I assume that you needed to change the id at runtime
                        to modify styling or something? If so, add/remove
                        custom classnames instead.

                        - Todd

                        --- digeomel <digeomel@...> wrote:

                        > Are you refering to my old method of using id
                        > (mnu.element.id) or the
                        > last one (mnu.id)?
                        >
                        > I've read the docs, but currently this was the only
                        > fast way to get it
                        > (partially) working again.
                        >
                        > What if you want to change the id dynamically at
                        > runtime?
                        >
                        >
                        > --- In ydn-javascript@yahoogroups.com, Todd Kloots
                        > <kloots@...> wrote:
                        > >
                        > > You're not use the id property correctly here.
                        > You need to set the id
                        > via the MenuItem's set of configuration properties
                        > that are passed to
                        > the constructor. This is noted in the docs:
                        > >
                        > >
                        >
                        http://developer.yahoo.com/yui/docs/YAHOO.widget.MenuItem.html#id
                        > >
                        > > - Todd
                        > >
                        > > ----- Original Message ----
                        > > From: digeomel digeomel@...
                        > > To: ydn-javascript@yahoogroups.com
                        > > Sent: Wednesday, February 21, 2007 8:47:07 AM
                        > > Subject: [ydn-javascript] Re: YUI 2.2.0 menu
                        > >
                        > >
                        > >
                        > >
                        > > No, it would be too hard for me to reproduce it,
                        > but I've already
                        > solved part of the problem.
                        > > It seems that the line (refer to my code posted
                        > above)
                        > >
                        > > mnuItem.element.id = "myElementId";
                        > >
                        > > must now be replaced by
                        > >
                        > > mnuItem.id = "myElementId";
                        > >
                        > > And all menu items will work fine again across
                        > browsers.
                        > > My problem is now that I can't get the icons for
                        > the menu items to
                        > show, in other words, although the <li>'s id should
                        > change with the code
                        > above, and thus show the related icon specified in
                        > the css, it doesn't.
                        > Any ideas?
                        > >
                        > >
                        > >
                        > > --- In ydn-javascript@yahoogroups.com, Todd Kloots
                        > kloots@ wrote:
                        > > >
                        > > > Can you please provide a link or code sample
                        > that demonstrates how
                        > to repro?
                        > > >
                        > > > ----- Original Message ----
                        > > > From: digeomel digeomel@
                        > > > To: ydn-javascript@yahoogroups!
                        > > .com
                        > > > Sent: Wednesday, February 21, 2007 6:10:10 AM
                        > > > Subject: [ydn-javascript] YUI 2.2.0 menu
                        > > >
                        > > >
                        > > >
                        > > >
                        > > > Hello,
                        > > >
                        > > > I just tried upgrading my web app to 2.2.0 and I
                        > noticed that MSIE7
                        > (haven't tried with 6 yet) complains about line 4355
                        > in menu.js:
                        > > >
                        > > > getItems: function() {
                        > > > var aGroups = this._aItemGroups,
                        > > > nGroups = aGroups.length;
                        > > > return (
                        > > > (nGroups == 1) ? aGroups[0] :
                        > > >
                        > (Array.prototype.concat.apply([], aGroups))
                        > > > );
                        > > > },
                        > > >
                        > > > Claiming that 'length' is null or not an object.
                        > > >
                        > > > I have a context menu which changes dynamically,
                        > and sometimes a
                        > menu item may become a submenu (depending on the
                        > context). On Firefox it
                        > wo!
                        > > > rks ok. I work in HTML 4.01 strict mode.
                        > > > I went through the README file for the menu and
                        > I can't see anything
                        > that should be affe!
                        > > cted.
                        > > > Any ideas what's going on?
                        > > >
                        > > > BTW, the onc
                        > > lick config property is a great addition to the
                        > menu class!
                        > > >
                        > > > Thanks in advance.
                        > > >
                        > >
                        >
                        >
                        >
                        >
                        > ------------------------ Yahoo! Groups Sponsor
                        > --------------------~-->
                        > Great things are happening at Yahoo! Groups. See
                        > the new email design.
                        >
                        http://us.click.yahoo.com/lOt0.A/hOaOAA/yQLSAA/edFolB/TM
                        >
                        --------------------------------------------------------------------~->
                        >
                        >
                        >
                        > Yahoo! Groups - Join or create groups, clubs, forums
                        > & communities. Links
                        >
                        > (Yahoo! ID required)
                        >
                        > mailto:ydn-javascript-fullfeatured@yahoogroups.com
                        >
                        >
                        > http://docs.yahoo.com/info/terms/
                        >
                        >
                        >
                        >
                        >
                      • Todd Kloots
                        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
                        Message 11 of 13 , Feb 22, 2007
                        • 0 Attachment
                          "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....
                          > >
                          >
                          >
                        • Locutus of Borg
                          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
                          Message 12 of 13 , Feb 28, 2007
                          • 0 Attachment
                            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....
                            > > >
                            > >
                            > >
                            >
                          • 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 13 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.