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

Re: Check SubMenu Items

Expand Messages
  • arup832003
    Hi Caridy Patino, Thanks for your reply. In my example var items = oMenu.getSubmenus(); not giving the set of SubMenu Items attached to that MenuItem. I just
    Message 1 of 6 , Jul 1, 2008
    • 0 Attachment
      Hi Caridy Patino,

      Thanks for your reply.
      In my example
      var items = oMenu.getSubmenus(); not giving the set of SubMenu Items
      attached to that MenuItem.

      I just want to check/unchech the submenu Items by clicking on them. I
      can do that by using the "checked" configuration property of
      YAHOO.widget.MenuItem.

      But, I amn't able to get all the Submenu Items of the selected
      MenuItem as an Object array of YAHOO.widget.MenuItem.

      Here is the code.

      *************************************************************
      <script type="text/javascript">

      /*
      Initialize and render the Menu when its elements are
      ready
      to be scripted.
      */

      var oMenu;

      YAHOO.util.Event.onContentReady("productsandservices",
      function () {

      /*
      Instantiate a Menu: The first argument passed to the
      constructor is the id of the element in the page
      representing the Menu; the second is an object
      literal
      of configuration properties.
      */

      oMenu = new YAHOO.widget.Menu("productsandservices", {
      position:
      "static",
      hidedelay: 750,
      lazyload: true });


      /*
      Define an array of object literals, each containing
      the data necessary to create a submenu.
      */

      var aSubmenuData = [

      {
      id: "communication",
      itemdata: [
      { text: "360",checked: true, url:
      "javascript:checkItem();" },
      { text: "Alerts", url:
      "http://alerts.yahoo.com" },
      { text: "Avatars", url:
      "http://avatars.yahoo.com" },
      { text: "Groups", url:
      "http://groups.yahoo.com " },
      { text: "Internet Access", url:
      "http://promo.yahoo.com/broadband" }
      ]
      }

      ];


      // Subscribe to the Menu instance's "beforeRender" event

      oMenu.subscribe("beforeRender", function () {

      if (this.getRoot() == this) {

      this.getItem(0).cfg.setProperty("submenu",
      aSubmenuData[0]);
      }

      });


      /*
      Call the "render" method with no arguments since the
      markup for this Menu instance is already exists
      in the page.
      */

      oMenu.render();

      });


      function checkItem()
      {
      //Check the Selected SubMenuItem.

      //var menuitem=oMenu.getItem(0).cfg.getProperty('checked');


      //oMenu.getItem(0).cfg.setProperty('checked',true);

      var subMenuArr = oMenu.getSubmenus();
      alert(subMenuArr.join('|'));

      }

      </script>
      *************************************************************

      Please, help me to get rid of this Issue.

      Thanks,
      Arup

      --- In ydn-javascript@yahoogroups.com, "Caridy Patino" <caridy@...> wrote:
      >
      > Hey,
      >
      > To access to a certain element based on the index:
      > var label = oMenu.getItem(0).cfg.getProperty("text");
      >
      > To retrieve an array of all submenus that are direct descendants of a
      > Menu instance, use the getSubmenus method:
      > var items = oMenu.getSubmenus();
      >
      > Best Regards,
      > Caridy Patino (caridy at yahoo-inc.com)
      >
      > --- In ydn-javascript@yahoogroups.com, "arup832003" <arup832003@>
      > wrote:
      > >
      > > Hi all,
      > >
      > > How can I access all the SubMenu Items of a MenuItem. So that, I can
      > > manipulate it's Configuration properties.
      > >
      > > But, I amn't getting How can I access all the SubMenu Items of a
      > > MenuIten as an object array of MenuItems.
      > >
      > > Please, help me in this regard.
      > >
      >
    • Todd Kloots
      Arup - To get a reference to the submenu of a MenuItem, use the submenu configuration property. Then use the getItems method to retrieve an array of the
      Message 2 of 6 , Jul 1, 2008
      • 0 Attachment
        Arup -

        To get a reference to the submenu of a MenuItem, use the "submenu"
        configuration property. Then use the "getItems" method to retrieve an
        array of the items in that submenu:

        var aItems = oMenu.getItem(0).cfg.getProperty("submenu").getItems();

        Got it?

        - Todd

        arup832003 wrote:
        >
        > Hi Caridy Patino,
        >
        > Thanks for your reply.
        > In my example
        > var items = oMenu.getSubmenus(); not giving the set of SubMenu Items
        > attached to that MenuItem.
        >
        > I just want to check/unchech the submenu Items by clicking on them. I
        > can do that by using the "checked" configuration property of
        > YAHOO.widget.MenuItem.
        >
        > But, I amn't able to get all the Submenu Items of the selected
        > MenuItem as an Object array of YAHOO.widget.MenuItem.
        >
        > Here is the code.
        >
        > *************************************************************
        > <script type="text/javascript">
        >
        > /*
        > Initialize and render the Menu when its elements are
        > ready
        > to be scripted.
        > */
        >
        > var oMenu;
        >
        > YAHOO.util.Event.onContentReady("productsandservices",
        > function () {
        >
        > /*
        > Instantiate a Menu: The first argument passed to the
        > constructor is the id of the element in the page
        > representing the Menu; the second is an object
        > literal
        > of configuration properties.
        > */
        >
        > oMenu = new YAHOO.widget.Menu("productsandservices", {
        > position:
        > "static",
        > hidedelay: 750,
        > lazyload: true });
        >
        > /*
        > Define an array of object literals, each containing
        > the data necessary to create a submenu.
        > */
        >
        > var aSubmenuData = [
        >
        > {
        > id: "communication",
        > itemdata: [
        > { text: "360",checked: true, url:
        > "javascript:checkItem();" },
        > { text: "Alerts", url:
        > "http://alerts.yahoo.com <http://alerts.yahoo.com>" },
        > { text: "Avatars", url:
        > "http://avatars.yahoo.com <http://avatars.yahoo.com>" },
        > { text: "Groups", url:
        > "http://groups.yahoo.com <http://groups.yahoo.com> " },
        > { text: "Internet Access", url:
        > "http://promo.yahoo.com/broadband <http://promo.yahoo.com/broadband>" }
        > ]
        > }
        >
        > ];
        >
        > // Subscribe to the Menu instance's "beforeRender" event
        >
        > oMenu.subscribe("beforeRender", function () {
        >
        > if (this.getRoot() == this) {
        >
        > this.getItem(0).cfg.setProperty("submenu",
        > aSubmenuData[0]);
        > }
        >
        > });
        >
        > /*
        > Call the "render" method with no arguments since the
        > markup for this Menu instance is already exists
        > in the page.
        > */
        >
        > oMenu.render();
        >
        > });
        >
        > function checkItem()
        > {
        > //Check the Selected SubMenuItem.
        >
        > //var menuitem=oMenu.getItem(0).cfg.getProperty('checked');
        >
        > //oMenu.getItem(0).cfg.setProperty('checked',true);
        >
        > var subMenuArr = oMenu.getSubmenus();
        > alert(subMenuArr.join('|'));
        >
        > }
        >
        > </script>
        > *************************************************************
        >
        > Please, help me to get rid of this Issue.
        >
        > Thanks,
        > Arup
        >
        > --- In ydn-javascript@yahoogroups.com
        > <mailto:ydn-javascript%40yahoogroups.com>, "Caridy Patino"
        > <caridy@...> wrote:
        > >
        > > Hey,
        > >
        > > To access to a certain element based on the index:
        > > var label = oMenu.getItem(0).cfg.getProperty("text");
        > >
        > > To retrieve an array of all submenus that are direct descendants of a
        > > Menu instance, use the getSubmenus method:
        > > var items = oMenu.getSubmenus();
        > >
        > > Best Regards,
        > > Caridy Patino (caridy at yahoo-inc.com)
        > >
        > > --- In ydn-javascript@yahoogroups.com
        > <mailto:ydn-javascript%40yahoogroups.com>, "arup832003" <arup832003@>
        > > wrote:
        > > >
        > > > Hi all,
        > > >
        > > > How can I access all the SubMenu Items of a MenuItem. So that, I can
        > > > manipulate it's Configuration properties.
        > > >
        > > > But, I amn't getting How can I access all the SubMenu Items of a
        > > > MenuIten as an object array of MenuItems.
        > > >
        > > > Please, help me in this regard.
        > > >
        > >
        >
        >
      • arup832003
        Hi Todd, Thanks a lot. My Problem get solved. Thank you again... ... } ... of a ... I can
        Message 3 of 6 , Jul 2, 2008
        • 0 Attachment
          Hi Todd,

          Thanks a lot.
          My Problem get solved.

          Thank you again...

          --- In ydn-javascript@yahoogroups.com, Todd Kloots <kloots@...> wrote:
          >
          > Arup -
          >
          > To get a reference to the submenu of a MenuItem, use the "submenu"
          > configuration property. Then use the "getItems" method to retrieve an
          > array of the items in that submenu:
          >
          > var aItems = oMenu.getItem(0).cfg.getProperty("submenu").getItems();
          >
          > Got it?
          >
          > - Todd
          >
          > arup832003 wrote:
          > >
          > > Hi Caridy Patino,
          > >
          > > Thanks for your reply.
          > > In my example
          > > var items = oMenu.getSubmenus(); not giving the set of SubMenu Items
          > > attached to that MenuItem.
          > >
          > > I just want to check/unchech the submenu Items by clicking on them. I
          > > can do that by using the "checked" configuration property of
          > > YAHOO.widget.MenuItem.
          > >
          > > But, I amn't able to get all the Submenu Items of the selected
          > > MenuItem as an Object array of YAHOO.widget.MenuItem.
          > >
          > > Here is the code.
          > >
          > > *************************************************************
          > > <script type="text/javascript">
          > >
          > > /*
          > > Initialize and render the Menu when its elements are
          > > ready
          > > to be scripted.
          > > */
          > >
          > > var oMenu;
          > >
          > > YAHOO.util.Event.onContentReady("productsandservices",
          > > function () {
          > >
          > > /*
          > > Instantiate a Menu: The first argument passed to the
          > > constructor is the id of the element in the page
          > > representing the Menu; the second is an object
          > > literal
          > > of configuration properties.
          > > */
          > >
          > > oMenu = new YAHOO.widget.Menu("productsandservices", {
          > > position:
          > > "static",
          > > hidedelay: 750,
          > > lazyload: true });
          > >
          > > /*
          > > Define an array of object literals, each containing
          > > the data necessary to create a submenu.
          > > */
          > >
          > > var aSubmenuData = [
          > >
          > > {
          > > id: "communication",
          > > itemdata: [
          > > { text: "360",checked: true, url:
          > > "javascript:checkItem();" },
          > > { text: "Alerts", url:
          > > "http://alerts.yahoo.com <http://alerts.yahoo.com>" },
          > > { text: "Avatars", url:
          > > "http://avatars.yahoo.com <http://avatars.yahoo.com>" },
          > > { text: "Groups", url:
          > > "http://groups.yahoo.com <http://groups.yahoo.com> " },
          > > { text: "Internet Access", url:
          > > "http://promo.yahoo.com/broadband
          <http://promo.yahoo.com/broadband>" }
          > > ]
          > > }
          > >
          > > ];
          > >
          > > // Subscribe to the Menu instance's "beforeRender" event
          > >
          > > oMenu.subscribe("beforeRender", function () {
          > >
          > > if (this.getRoot() == this) {
          > >
          > > this.getItem(0).cfg.setProperty("submenu",
          > > aSubmenuData[0]);
          > > }
          > >
          > > });
          > >
          > > /*
          > > Call the "render" method with no arguments since the
          > > markup for this Menu instance is already exists
          > > in the page.
          > > */
          > >
          > > oMenu.render();
          > >
          > > });
          > >
          > > function checkItem()
          > > {
          > > //Check the Selected SubMenuItem.
          > >
          > > //var menuitem=oMenu.getItem(0).cfg.getProperty('checked');
          > >
          > > //oMenu.getItem(0).cfg.setProperty('checked',true);
          > >
          > > var subMenuArr = oMenu.getSubmenus();
          > > alert(subMenuArr.join('|'));
          > >
          > > }
          > >
          > > </script>
          > > *************************************************************
          > >
          > > Please, help me to get rid of this Issue.
          > >
          > > Thanks,
          > > Arup
          > >
          > > --- In ydn-javascript@yahoogroups.com
          > > <mailto:ydn-javascript%40yahoogroups.com>, "Caridy Patino"
          > > <caridy@> wrote:
          > > >
          > > > Hey,
          > > >
          > > > To access to a certain element based on the index:
          > > > var label = oMenu.getItem(0).cfg.getProperty("text");
          > > >
          > > > To retrieve an array of all submenus that are direct descendants
          of a
          > > > Menu instance, use the getSubmenus method:
          > > > var items = oMenu.getSubmenus();
          > > >
          > > > Best Regards,
          > > > Caridy Patino (caridy at yahoo-inc.com)
          > > >
          > > > --- In ydn-javascript@yahoogroups.com
          > > <mailto:ydn-javascript%40yahoogroups.com>, "arup832003" <arup832003@>
          > > > wrote:
          > > > >
          > > > > Hi all,
          > > > >
          > > > > How can I access all the SubMenu Items of a MenuItem. So that,
          I can
          > > > > manipulate it's Configuration properties.
          > > > >
          > > > > But, I amn't getting How can I access all the SubMenu Items of a
          > > > > MenuIten as an object array of MenuItems.
          > > > >
          > > > > Please, help me in this regard.
          > > > >
          > > >
          > >
          > >
          >
        Your message has been successfully submitted and would be delivered to recipients shortly.