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

Context Menu v0.12.1 - Invalid Pointer Error

Expand Messages
  • Kenny
    following code throws an Invalid Pointer error. am i missing something ?! var oContextMenu = new
    Message 1 of 6 , Jan 31, 2007
      following code throws an Invalid Pointer error.
      am i missing something ?!

      <script type="text/javascript">
         
          var oContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu", { trigger: document } );

          oContextMenu.addItem(new YAHOO.widget.MenuItem("Yahoo", { url : "http://yahoo.com"}));        

          oContextMenu.render(document.body);

      </script>



      The fish are biting.
      Get more visitors on your site using Yahoo! Search Marketing.
    • Eric Miraglia
      Kenny, Try this: var oContextMenu = new YAHOO.widget.ContextMenu( mycontextmenu , { trigger: document } ); oContextMenu.addItem({text: Yahoo ,
      Message 2 of 6 , Jan 31, 2007
        Kenny,

        Try this:

           var oContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu", { trigger: document } );

            oContextMenu.addItem({text:"Yahoo", url:"http://yahoo.com"});         

            oContextMenu.render(document.body);

        For a sophisticated example of the ContextMenu in action, see the ContextMenu example (third to last in the examples list).

        Regards,
        Eric


        ______________________________________________
        Eric Miraglia
        Yahoo! User Interface Library



        On Jan 31, 2007, at 8:07 AM, Kenny wrote:

        following code throws an Invalid Pointer error.
        am i missing something ?!

        <script type="text/javascript">
           
            var oContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu", { trigger: document } );

            oContextMenu.addItem(new YAHOO.widget.MenuItem("Yahoo", { url : "http://yahoo.com"}));        

            oContextMenu.render(document.body);

        </script>




        The fish are biting.
        Get more visitors on your site using Yahoo! Search Marketing.


      • Daniel Nunes
        Hey, what am I doing wrong here? I followed the code example in the YUI home page for the context menu:
        Message 3 of 6 , Feb 23, 2007
          Hey, what am I doing wrong here? I followed the code example in the
          YUI home page for the context menu:

          <html>
          <head>
          <link rel="stylesheet" type="text/css" href="yui/assets/fonts.css">
          <link rel="stylesheet" type="text/css" href="yui/assets/menu.css">
          <!-- Namespace source file -->
          <script type="text/javascript" src = "yui/yahoo.js" ></script>
          <!-- Dependency source files -->
          <script type="text/javascript" src = "yui/dom.js" ></script>
          <script type="text/javascript" src = "yui/event.js" ></script>
          <!-- Drag and Drop source file -->
          <script type="text/javascript" src = "yui/dragdrop.js" ></script>
          <script type="text/javascript" src="yui/container_core.js"></script>
          <!-- Source File -->
          <script type="text/javascript" src="yui/menu.js"></script>
          <script type="text/javascript">
          var oContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu",
          { trigger: document } );

          oContextMenu.addItem("cut");
          oContextMenu.addItem("copy");
          oContextMenu.addItem("paste");

          oContextMenu.render();
          </script>
          </head>
          <style type="text/css">
          #mycontextmenu{
          background-color:red;
          width:120px;
          height:120px;
          }
          </style>
          <body>

          <table border="1" id="grade">
          <tr><td>aaa</td></tr>
          <tr><td>bbb</td></tr>
          <tr><td>bbb</td></tr>
          </table>
          </body>

          </html>

          *******
          Wasn't this code supposed to show a menu wherever I clicked on the
          document body? Well, it simply does nothing nor throws an error. Just
          opens the commom menu for viewing the source code, page properties,
          etc....Should I do something else? All the libraries are imported, so
          what's wrong??
        • dav.glass@yahoo.com
          Daniel -- Try this: var oContextMenu = null; function init() { oContextMenu = new YAHOO.widget.ContextMenu( mycontextmenu , { trigger: document } );
          Message 4 of 6 , Feb 23, 2007
            Daniel --

            Try this:

            var oContextMenu = null;
            function init() {
                oContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu", { trigger: document } );
                oContextMenu.addItem("cut");
                oContextMenu.addItem("copy");
                oContextMenu.addItem("paste");
                oContextMenu.render();
            }

            YAHOO.util.Event.addListener(window, 'load', init);
             
            Hope that helps 8-)
            Dav

            Dav Glass
            dav.glass@...
            blog.davglass.com


            + Windows: n. - The most successful computer virus, ever. +
            + A computer without a Microsoft operating system is like a dog
            without bricks tied to its head +
            + A Microsoft Certified Systems Engineer is to computing what a
            McDonalds Certified Food Specialist is to fine cuisine +


            ----- Original Message ----
            From: Daniel Nunes <jaywalker1983@...>
            To: ydn-javascript@yahoogroups.com
            Sent: Friday, February 23, 2007 10:44:01 AM
            Subject: [ydn-javascript] Context Menu v0.12.1 Does Nothing...

            Hey, what am I doing wrong here? I followed the code example in the
            YUI home page for the context menu:

            <html>
            <head>
            <link rel="stylesheet" type="text/css" href="yui/assets/fonts.css">
                <link rel="stylesheet" type="text/css" href="yui/assets/menu.css">
                <!-- Namespace source file -->  
                <script type="text/javascript" src = "yui/yahoo.js" ></script>
                <!-- Dependency source files -->  
                <script type="text/javascript" src = "yui/dom.js" ></script>
                <script type="text/javascript" src = "yui/event.js" ></script>
                <!-- Drag and Drop source file -->  
                <script type="text/javascript" src = "yui/dragdrop.js" ></script>
                <script type="text/javascript" src="yui/container_core.js"></script>
                <!-- Source File -->
                <script type="text/javascript" src="yui/menu.js"></script>
            <script type="text/javascript">
                    var oContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu",
            { trigger: document } );
                
                    oContextMenu.addItem("cut");
                    oContextMenu.addItem("copy");
                    oContextMenu.addItem("paste");
                    
                    oContextMenu.render();
                </script>
            </head>
            <style type="text/css">
                #mycontextmenu{
                    background-color:red;
                    width:120px;
                    height:120px;
                }
            </style>
            <body>

            <table border="1" id="grade">
                <tr><td>aaa</td></tr>
                <tr><td>bbb</td></tr>
                <tr><td>bbb</td></tr>
            </table>
            </body>

            </html>

            *******
            Wasn't this code supposed to show a menu wherever I clicked on the
            document body? Well, it simply does nothing nor throws an error. Just
            opens the commom menu for viewing the source code, page properties,
            etc....Should I do something else? All the libraries are imported, so
            what's wrong??



            ------------------------ Yahoo! Groups Sponsor --------------------~-->
            See what's inside the new Yahoo! Groups email.
            http://us.click.yahoo.com/0It09A/bOaOAA/yQLSAA/edFolB/TM
            --------------------------------------------------------------------~->


            Yahoo! Groups - Join or create groups, clubs, forums &amp; communities. Links

            <*> To visit your group on the web, go to:
                http://groups.yahoo.com/group/ydn-javascript/

            <*> Your email settings:
                Individual Email | Traditional

            <*> To change settings online go to:
                http://groups.yahoo.com/group/ydn-javascript/join
                (Yahoo! ID required)

            <*> To change settings via email:
                mailto:ydn-javascript-digest@yahoogroups.com
                mailto:ydn-javascript-fullfeatured@yahoogroups.com

            <*> To unsubscribe from this group, send an email to:
                ydn-javascript-unsubscribe@yahoogroups.com

            <*> Your use of Yahoo! Groups - Join or create groups, clubs, forums &amp; communities. is subject to:
                http://docs.yahoo.com/info/terms/


          • Daniel Nunes
            That did not worked also, but.... adding render(document.body) did work. But here is a question: Why do I have to add it with a window event listener?? Why
            Message 5 of 6 , Feb 23, 2007
              That did not worked also, but.... adding render(document.body) did
              work. But here is a question: Why do I have to add it with a window
              event listener?? Why can't I use it without it?

              Thanks Pal. You helped a lot! =)
              --- In ydn-javascript@yahoogroups.com, dav.glass@... wrote:
              >
              > Daniel --
              >
              > Try this:
              >
              > var oContextMenu = null;
              > function init() {
              > oContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu", {
              trigger: document } );
              > oContextMenu.addItem("cut");
              > oContextMenu.addItem("copy");
              > oContextMenu.addItem("paste");
              > oContextMenu.render();
              > }
              >
              > YAHOO.util.Event.addListener(window, 'load', init);
              >
              > Hope that helps 8-)
              > Dav
              >
              >
              > Dav Glass
              > dav.glass@...
              > blog.davglass.com
              >
              >
              > + Windows: n. - The most successful computer virus, ever. +
              > + A computer without a Microsoft operating system is like a dog
              > without bricks tied to its head +
              > + A Microsoft Certified Systems Engineer is to computing what a
              > McDonalds Certified Food Specialist is to fine cuisine +
              >
              > ----- Original Message ----
              > From: Daniel Nunes <jaywalker1983@...>
              > To: ydn-javascript@yahoogroups.com
              > Sent: Friday, February 23, 2007 10:44:01 AM
              > Subject: [ydn-javascript] Context Menu v0.12.1 Does Nothing...
              >
              > Hey, what am I doing wrong here? I followed the code example in the
              > YUI home page for the context menu:
              >
              > <html>
              > <head>
              > <link rel="stylesheet" type="text/css" href="yui/assets/fonts.css">
              > <link rel="stylesheet" type="text/css" href="yui/assets/menu.css">
              > <!-- Namespace source file -->
              > <script type="text/javascript" src = "yui/yahoo.js" ></script>
              > <!-- Dependency source files -->
              > <script type="text/javascript" src = "yui/dom.js" ></script>
              > <script type="text/javascript" src = "yui/event.js" ></script>
              > <!-- Drag and Drop source file -->
              > <script type="text/javascript" src = "yui/dragdrop.js" ></script>
              > <script type="text/javascript"
              src="yui/container_core.js"></script>
              > <!-- Source File -->
              > <script type="text/javascript" src="yui/menu.js"></script>
              > <script type="text/javascript">
              > var oContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu",
              > { trigger: document } );
              >
              > oContextMenu.addItem("cut");
              > oContextMenu.addItem("copy");
              > oContextMenu.addItem("paste");
              >
              > oContextMenu.render();
              > </script>
              > </head>
              > <style type="text/css">
              > #mycontextmenu{
              > background-color:red;
              > width:120px;
              > height:120px;
              > }
              > </style>
              > <body>
              >
              > <table border="1" id="grade">
              > <tr><td>aaa</td></tr>
              > <tr><td>bbb</td></tr>
              > <tr><td>bbb</td></tr>
              > </table>
              > </body>
              >
              > </html>
              >
              > *******
              > Wasn't this code supposed to show a menu wherever I clicked on the
              > document body? Well, it simply does nothing nor throws an error. Just
              > opens the commom menu for viewing the source code, page properties,
              > etc....Should I do something else? All the libraries are imported, so
              > what's wrong??
              >
              >
              >
              >
              >
              > Yahoo! Groups - Join or create groups, clubs, forums &
              communities. Links
              >
            • Todd Kloots
              Daniel - You need to wait for the DOM element(s) that are the basis for your menu to be loaded by the browser before you can instantiate a Menu, MenuBar or
              Message 6 of 6 , Feb 25, 2007
                Daniel -

                You need to wait for the DOM element(s) that are the basis for your menu to be loaded by the browser before you can instantiate a Menu, MenuBar or ContextMenu instance. If you don't want to wait for the window's "load" event to fire, you can use the Event utility's "onContentReady" method instead:

                http://developer.yahoo.com/yui/event/#onavailable

                Just about every Menu example that is based on existing markup use this technique. If you haven't already looked at the Menu examples, you can find them here:

                http://developer.yahoo.com/yui/examples/menu/

                - Todd

                ----- Original Message ----
                From: Daniel Nunes <jaywalker1983@...>
                To: ydn-javascript@yahoogroups.com
                Sent: Friday, February 23, 2007 12:05:50 PM
                Subject: [ydn-javascript] Re: Context Menu v0.12.1 Does Nothing...

                That did not worked also, but.... adding render(document.body) did
                work. But here is a question: Why do I have to add it with a window
                event listener?? Why can't I use it without it?

                Thanks Pal. You helped a lot! =)
                --- In ydn-javascript@yahoogroups.com, dav.glass@... wrote:
                >
                > Daniel --
                >
                > Try this:
                >
                > var oContextMenu = null;
                > function init() {
                > oContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu", {
                trigger: document } );
                > oContextMenu.addItem("cut");
                > oContextMenu.addItem("copy");
                > oContextMenu.addItem("paste");
                > oContextMenu.render();
                > }
                >
                > YAHOO.util.Event.addListener(window, 'load', init);
                >
                > Hope that helps 8-)
                > Dav
                >
                >
                > Dav Glass
                > dav.glass@...
                > blog.davglass.com
                >
                >
                > + Windows: n. - The most successful computer virus, ever. +
                > + A computer without a Microsoft operating system is like a dog
                > without bricks tied to its head +
                > + A Microsoft Certified Systems Engineer is to computing what a
                > McDonalds Certified Food Specialist is to fine cuisine +
                >
                > ----- Original Message ----
                > From: Daniel Nunes <jaywalker1983@...>
                > To: ydn-javascript@yahoogroups.com
                > Sent: Friday, February 23, 2007 10:44:01 AM
                > Subject: [ydn-javascript] Context Menu v0.12.1 Does Nothing...
                >
                > Hey, what am I doing wrong here? I followed the code example in the
                > YUI home page for the context menu:
                >
                > <html>
                > <head>
                > <link rel="stylesheet" type="text/css" href="yui/assets/fonts.css">
                > <link rel="stylesheet" type="text/css" href="yui/assets/menu.css">
                > <!-- Namespace source file -->
                > <script type="text/javascript" src = "yui/yahoo.js" ></script>
                > <!-- Dependency source files -->
                > <script type="text/javascript" src = "yui/dom.js" ></script>
                > <script type="text/javascript" src = "yui/event.js" ></script>
                > <!-- Drag and Drop source file -->
                > <script type="text/javascript" src = "yui/dragdrop.js" ></script>
                > <script type="text/javascript"
                src="yui/container_core.js"></script>
                > <!-- Source File -->
                > <script type="text/javascript" src="yui/menu.js"></script>
                > <script type="text/javascript">
                > var oContextMenu = new YAHOO.widget.ContextMenu("mycontextmenu",
                > { trigger: document } );
                >
                > oContextMenu.addItem("cut");
                > oContextMenu.addItem("copy");
                > oContextMenu.addItem("paste");
                >
                > oContextMenu.render();
                > </script>
                > </head>
                > <style type="text/css">
                > #mycontextmenu{
                > background-color:red;
                > width:120px;
                > height:120px;
                > }
                > </style>
                > <body>
                >
                > <table border="1" id="grade">
                > <tr><td>aaa</td></tr>
                > <tr><td>bbb</td></tr>
                > <tr><td>bbb</td></tr>
                > </table>
                > </body>
                >
                > </html>
                >
                > *******
                > Wasn't this code supposed to show a menu wherever I clicked on the
                > document body? Well, it simply does nothing nor throws an error. Just
                > opens the commom menu for viewing the source code, page properties,
                > etc....Should I do something else? All the libraries are imported, so
                > what's wrong??
                >
                >
                >
                >
                >
                > Yahoo! Groups - Join or create groups, clubs, forums &
                communities. Links
                >






                Yahoo! Groups - Join or create groups, clubs, forums & communities. Links
              Your message has been successfully submitted and would be delivered to recipients shortly.