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

52251Re: [ydn-javascript] Replacing the content of a Button's Menu

Expand Messages
  • George Papaioannou
    Dec 10, 2009
      I changed the previous code with the code below and partially is working. The problem is that in case the oMenuAgent menu is not renderer (the else part) the new item is added to the current items and not replacing the previous content. Any ideas ?

              var onMenuclickSuperAgent = function (p_sType, p_aArgs) {

                  var oEvent = p_aArgs[0],    //    DOM event

                      oMenuItem = p_aArgs[1];    //    MenuItem instance that was the
                                              //    target of the event

                  if (oMenuItem) {

                      var oMenuAgent = oMenuButton2.getMenu();

                      //  determine if the Button's Menu has been rendered.
                      if (YAHOO.util.Dom.inDocument(oMenuButton2.getMenu().element)) {

                          oMenuAgent.addItems([{ text: "Four", value: 4 }]);
                       } else {

                         oMenuAgent.itemData =  [{ text: "Four", value: 4 },{ text: "Five", value: 5 }];

      --- Στις Παρ., 11/12/09, ο/η George <sdancer75@...> έγραψε:

      Από: George <sdancer75@...>
      Θέμα: [ydn-javascript] Replacing the content of a Button's Menu
      Προς: ydn-javascript@yahoogroups.com
      Ημερομηνία: Παρασκευή, 11 Δεκέμβριος 2009, 0:10



      Trying to replace the content of a button's menu from an event inside  of another button menu was unsuccessful. I create the 2 menus like below.

      var oMenuButton2 = new YAHOO.widget. Button("menubutt on2",{ type: "menu", menu: "agentsmenu" });
      oMenuButton2. getMenu() .subscribe( "click", onMenuclickAgent) ;

      var oMenuButton3 = new YAHOO.widget. Button("menubutt on3",{ type: "menu", menu: "superagentsmenu" });
      oMenuButton3. getMenu() .subscribe( "click", onMenuclickSuperAge nt);

      I am trying to change the content of oMenuButton2 menu, from the a click event like below, but it does not work. What may be wrong ?

      var onMenuclickSuperAge nt = function (p_sType, p_aArgs) {

      var oEvent = p_aArgs[0],    //    DOM event

      oMenuItem = p_aArgs[1];    //    MenuItem instance that was the
      //    target of the event
          if (oMenuItem) {

                          var oMenuAgent = oMenuButton2. getMenu() ;
                          oMenuAgent.clearCon tent();
                          oMenuAgent.render( );
                          oMenuAgent.itemData = menuitems;



      Χρησιμοποιείτε Yahoo!
      Βαρεθήκατε τα ενοχλητικά μηνύ ματα (spam); Το Yahoo! Mail διαθέτει την καλύτερη δυνατή προστασία κατά των ενοχλητικών μηνυμάτων
    • Show all 2 messages in this topic