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

Toggles checked in menu items

Expand Messages
  • dean.grubb
    Hi can somebody tell be why this doesn t work? var aItems = oMenu.getItems(); for (var x = 0; x
    Message 1 of 7 , Aug 30, 2007
      Hi can somebody tell be why this doesn't work?

      var aItems = oMenu.getItems();
      for (var x = 0; x <= aItems.length; x++)
      {
      oMenu.getItem(i).cfg.setProperty("checked", false);
      }

      Where this does?

      var x=0;
      oMenu.getItem(x).cfg.setProperty("checked", false);

      Is there an in build function that enables you to easy toggle the
      state of a menu item?

      Also is it possible to pass a value from a markup menu? I know you can
      do it when the menu is built form javascript.
    • badotzo
      Sure - change oMenu.getItem(i). to oMenu.getItem(x). Simple spelling mistake ;-) ... can
      Message 2 of 7 , Aug 30, 2007
        Sure - change "oMenu.getItem(i)." to "oMenu.getItem(x)." Simple
        spelling mistake ;-)


        --- In ydn-javascript@yahoogroups.com, "dean.grubb" <dean@...> wrote:
        >
        > Hi can somebody tell be why this doesn't work?
        >
        > var aItems = oMenu.getItems();
        > for (var x = 0; x <= aItems.length; x++)
        > {
        > oMenu.getItem(i).cfg.setProperty("checked", false);
        > }
        >
        > Where this does?
        >
        > var x=0;
        > oMenu.getItem(x).cfg.setProperty("checked", false);
        >
        > Is there an in build function that enables you to easy toggle the
        > state of a menu item?
        >
        > Also is it possible to pass a value from a markup menu? I know you
        can
        > do it when the menu is built form javascript.
        >
      • dean.grubb
        nope sorry, typo my end when posting, here is the full menu code, and I get the error; Error: oMenu.getItem(x) has no properties
        Message 3 of 7 , Aug 30, 2007
          nope sorry, typo my end when posting, here is the full menu code, and
          I get the error;

          Error: oMenu.getItem(x) has no properties

          YAHOO.util.Event.onContentReady("menumonths", function () {
          var oMenu = new YAHOO.widget.Menu(
          "menumonths",
          {
          position: "static",
          hidedelay: 150,
          lazyload: false
          }
          );

          function onMenuClick(p_sType, p_aArgs) {
          var oEvent = p_aArgs[0];
          oMenuItem = p_aArgs[1];

          var aItems = oMenu.getItems();
          for (var x = 0; x <= aItems.length; x++)
          {
          oMenu.getItem(x).cfg.setProperty("checked", false);
          }

          oMenuItem.cfg.setProperty("checked", true);

          }

          oMenu.render();
          oMenu.subscribe("click", onMenuClick);

          });

          --- In ydn-javascript@yahoogroups.com, "badotzo" <of_interest@...> wrote:
          >
          > Sure - change "oMenu.getItem(i)." to "oMenu.getItem(x)." Simple
          > spelling mistake ;-)
          >
          >
          > --- In ydn-javascript@yahoogroups.com, "dean.grubb" <dean@> wrote:
          > >
          > > Hi can somebody tell be why this doesn't work?
          > >
          > > var aItems = oMenu.getItems();
          > > for (var x = 0; x <= aItems.length; x++)
          > > {
          > > oMenu.getItem(i).cfg.setProperty("checked", false);
          > > }
          > >
          > > Where this does?
          > >
          > > var x=0;
          > > oMenu.getItem(x).cfg.setProperty("checked", false);
          > >
          > > Is there an in build function that enables you to easy toggle the
          > > state of a menu item?
          > >
          > > Also is it possible to pass a value from a markup menu? I know you
          > can
          > > do it when the menu is built form javascript.
          > >
          >
        • badotzo
          ... ??
          Message 4 of 7 , Aug 30, 2007
            You go to the trouble of using a new var in the loop construct:

            > var aItems = oMenu.getItems();
            > for (var x = 0; x <= aItems.length; x++)

            but you use the source of the new var in the loop:

            > {
            > oMenu.getItem(x).cfg.setProperty("checked", false);
            > }

            Don't you mean:

            > {
            > aItems(x).cfg.setProperty("checked", false);
            > }

            ??
          • badotzo
            ... ??
            Message 5 of 7 , Aug 30, 2007
              You go to the trouble of using a new var in the loop construct:

              > var aItems = oMenu.getItems();
              > for (var x = 0; x <= aItems.length; x++)

              but you use the source of the new var in the loop:

              > {
              > oMenu.getItem(x).cfg.setProperty("checked", false);
              > }

              Don't you mean:

              > {
              > aItems(x).cfg.setProperty("checked", false);
              > }

              ??
            • badotzo
              Not only that, but you use DIFFERENT VARIABLE NAMES: var aItems = oMenu.getItems(); for (var x = 0; x
              Message 6 of 7 , Aug 30, 2007
                Not only that, but you use DIFFERENT VARIABLE NAMES:

                var aItems = oMenu.getItems();
                for (var x = 0; x <= aItems.length; x++)
                {
                oMenu.getItem(x).cfg.setProperty("checked", false);
                }

                oMenu.getItems()

                AND

                oMenu.getItem(x)

                Methinks that is also part of your confusion?
              • dean.grubb
                Ok, thanks for all that, this works; I think those extra vars confused me and the issue was with the length, oMenu.getItems().length returned the number of
                Message 7 of 7 , Aug 30, 2007
                  Ok, thanks for all that, this works; I think those extra vars confused
                  me and the issue was with the length, oMenu.getItems().length returned
                  the number of menu items and of course oMenu.getItem(x) needed to loop
                  from 0 to the number of items - 1;

                  <script>
                  YAHOO.util.Event.onContentReady("menumonths", function () {
                  var oMenu = new YAHOO.widget.Menu(
                  "menumonths",
                  {
                  position: "static",
                  hidedelay: 150,
                  lazyload: false
                  }
                  );

                  function onMenuClick(p_sType, p_aArgs) {
                  var oEvent = p_aArgs[0];
                  oMenuItem = p_aArgs[1];

                  items = oMenu.getItems().length;
                  for (var x = 0; x <= items-1; x++)
                  {
                  oMenu.getItem(x).cfg.setProperty("checked", false);
                  }

                  oMenuItem.cfg.setProperty("checked", true);

                  }

                  oMenu.render();
                  oMenu.subscribe("click", onMenuClick);

                  });
                  </script>




                  --- In ydn-javascript@yahoogroups.com, "badotzo" <of_interest@...> wrote:
                  >
                  > Not only that, but you use DIFFERENT VARIABLE NAMES:
                  >
                  > var aItems = oMenu.getItems();
                  > for (var x = 0; x <= aItems.length; x++)
                  > {
                  > oMenu.getItem(x).cfg.setProperty("checked", false);
                  > }
                  >
                  > oMenu.getItems()
                  >
                  > AND
                  >
                  > oMenu.getItem(x)
                  >
                  > Methinks that is also part of your confusion?
                  >
                Your message has been successfully submitted and would be delivered to recipients shortly.