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

Re: [ydn-javascript] can you unsubscribe clickEvents on individual menu items?

Expand Messages
  • Todd Kloots
    No, at least not in the way that you demonstrated in your example. You are adding a clickEvent listener to a menu, not individual items. Therefore, there
    Message 1 of 2 , Mar 1 6:48 PM
    • 0 Attachment
      No, at least not in the way that you demonstrated in your example. You are adding a "clickEvent" listener to a menu, not individual items. Therefore, there is nothing to unsubscribe from at the menu item level. That said, you CAN subscribe to the "clickEvent" of each item in your menu and then remove those via "unsubscribe" as necessary. For example:

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

      oMenu.addItems(
      [
      { text: "Item One", onclick: { fn:onMenuItemClick } },
      { text: "Item Two", onclick: { fn:onMenuItemClick, obj:"foo" } },
      { text: "Item Three", onclick: { fn:onMenuItemClick, obj: ["foo", "bar"] } },
      ]
      );

      oMenu.clickEvent.subscribe(onMenuClick, oMenu, true);

      oMenu.getItem(0).clickEvent.unsubscribe(onMenuItemClick);

      - Todd





      ----- Original Message ----
      From: iamakimmer <iamakimmer@...>
      To: ydn-javascript@yahoogroups.com
      Sent: Thursday, March 1, 2007 3:39:05 PM
      Subject: [ydn-javascript] can you unsubscribe clickEvents on individual menu items?

      Hi,

      I'm very new to YUI...and I was wondering, if you have a menu and you
      subscribe the menu to a function like this:
      oMenu.clickEvent.subscribe(onMenuClick, oMenu, true);

      can you unsubscribe individual menu items? I was thinking something like:
      oMenu.getItem(x).clickEvent.unsubscribe(onMenuClick);

      Is this possible?

      Thanks!!





      Yahoo! Groups Links
    Your message has been successfully submitted and would be delivered to recipients shortly.