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

Re: [ydn-javascript] Determining what fired an Event?

Expand Messages
  • Peter Foti
    Use the getTarget method. function handleFireEffect(ev){ // Get the target of this event var t = YAHOO.util.Event.getTarget(ev); // Check t to see if it s
    Message 1 of 5 , Dec 4, 2006
    • 0 Attachment
      Use the getTarget method.
       
      function handleFireEffect(ev){
        // Get the target of this event
        var t = YAHOO.util.Event.getTarget(ev);
        // Check t to see if it's link1
      ...
       
       
       
      ----- Original Message -----
      Sent: Monday, December 04, 2006 1:16 PM
      Subject: [ydn-javascript] Determining what fired an Event?

      Let's say I have this:

      YAHOO.util.Event. addListener( ['link1', 'link2', 'link3'], 'click',
      handleFireEffect) ;

      and my handler function:

      function handleFireEffect( ev) {

      // Only for link1

      eff.animate( );
      YAHOO.util.Event. stopEvent( ev);

      // link2 , do other stuff

      // link3 , different stuff here too

      }

      Is there any way for me to know whether link1, link2, or link3 was
      responsible for firing the handler event?

      I have tried a number of things, and none are working.

      Thank you.

    • dav.glass@yahoo.com
      You are looking for YAHOO.util.Event.getTarget(ev); like this: function handleFireEffect(ev) { var tar = YAHOO.util.Event.getTarget(ev); // tar is now a
      Message 2 of 5 , Dec 4, 2006
      • 0 Attachment
        You are looking for YAHOO.util.Event.getTarget(ev);

        like this:

        function handleFireEffect(ev) {
            var tar = YAHOO.util.Event.getTarget(ev);
            // tar is now a reference to the link that was clicked.
         
        Dav Glass
        dav.glass@...
        davglass.com
        618.694.3476

        + 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: tropeanojohn <tropeanojohn@...>
        To: ydn-javascript@yahoogroups.com
        Sent: Monday, December 4, 2006 10:16:56 AM
        Subject: [ydn-javascript] Determining what fired an Event?

        Let's say I have this:

        YAHOO.util.Event.addListener(['link1', 'link2', 'link3'], 'click',
        handleFireEffect);
            
        and my handler function:    

            function handleFireEffect(ev) {

                // Only for link1

                eff.animate();
                YAHOO.util.Event.stopEvent(ev);

               // link2 , do other stuff

               // link3 , different stuff here too

            }

        Is there any way for me to know whether link1, link2, or link3 was
        responsible for firing the handler event?

        I have tried a number of things, and none are working.

        Thank you.






        Yahoo! Groups 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 is subject to:
            http://docs.yahoo.com/info/terms/


      • Eric Miraglia
        Tropeanojohn, this.id within the context of your handler will tell you which link was clicked on. function handleFireEffect(ev) { alert(this.id); }
        Message 3 of 5 , Dec 4, 2006
        • 0 Attachment
          Tropeanojohn,

          this.id within the context of your handler will tell you which link was clicked on.

          <script>
          function handleFireEffect(ev) {
          alert(this.id);
          }
          YAHOO.util.Event.addListener(['link1', 'link2', 'link3'], 'click',handleFireEffect);
          </script>
          </head>

          <body>
          <a id="link1">one</a>
          <a id="link2">two</a>
          <a id="link3">three</a>
          </body>
          </html>

          Regards,
          Eric


          ______________________________________________
          Eric Miraglia
          Yahoo! Presentation Platform Engineering



          On Dec 4, 2006, at 10:16 AM, tropeanojohn wrote:

          Let's say I have this:

          YAHOO.util.Event.addListener(['link1', 'link2', 'link3'], 'click',
          handleFireEffect);

          and my handler function:

          function handleFireEffect(ev) {

          // Only for link1

          eff.animate();
          YAHOO.util.Event.stopEvent(ev);

          // link2 , do other stuff

          // link3 , different stuff here too

          }

          Is there any way for me to know whether link1, link2, or link3 was
          responsible for firing the handler event?

          I have tried a number of things, and none are working.

          Thank you.


        • tropeanojohn
          I tried this, and it does not work: var t = YAHOO.util.Event.getTarget(ev); alert(t.id); Any idea why my alert box comes up blank? Thank you.
          Message 4 of 5 , Dec 4, 2006
          • 0 Attachment
            I tried this, and it does not work:

            var t = YAHOO.util.Event.getTarget(ev);
            alert(t.id);

            Any idea why my alert box comes up blank?

            Thank you.

            --- In ydn-javascript@yahoogroups.com, "Peter Foti" <foti-1@...> wrote:
            >
            > Use the getTarget method.
            >
            > function handleFireEffect(ev){
            > // Get the target of this event
            > var t = YAHOO.util.Event.getTarget(ev);
            > // Check t to see if it's link1
            > ...
          Your message has been successfully submitted and would be delivered to recipients shortly.