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

Re: [ydn-javascript] recieve listElementID from list

Expand Messages
  • Adam Moore
    ... function clickHandler(e) { var n = YAHOO.util.Event.getTarget(e), id; // n could be a child of the li for (;;) { if (!n || n.id && n.id === nav ) { break;
    Message 1 of 5 , Oct 1, 2007
    • 0 Attachment
      On Mon, Oct 01, 2007 at 11:41:15PM -0000, rupnaldo wrote:
      > Hi,
      >
      > is there a way to recieve the id of the actual clicked Listelement?
      >
      > function clickHandler(e) {
      > }
      > YAHOO.util.Event.on("nav", "click", clickHandler);
      >
      >
      > <div id="nav">
      > <ul>
      > <li id="l_1">...</li>
      > ....
      > </ul>
      > </div>

      function clickHandler(e) {
      var n = YAHOO.util.Event.getTarget(e), id;
      // n could be a child of the li
      for (;;) {
      if (!n || n.id && n.id === "nav") {
      break; // no list item found
      } else if (n.id && n.id.indexOf("l_") > -1) {
      id = n.id;
      break;
      }
      }

      alert(id);
      }

      -Adam
    • Adam Moore
      ... Oops, left out a line: function clickHandler(e) { var n = YAHOO.util.Event.getTarget(e), id; // n could be a child of the li for (;;) { if (!n || n.id &&
      Message 2 of 5 , Oct 1, 2007
      • 0 Attachment
        On Mon, Oct 01, 2007 at 09:07:45PM -0700, Adam Moore wrote:
        > On Mon, Oct 01, 2007 at 11:41:15PM -0000, rupnaldo wrote:
        > > Hi,
        > >
        > > is there a way to recieve the id of the actual clicked Listelement?
        > >
        > > function clickHandler(e) {
        > > }
        > > YAHOO.util.Event.on("nav", "click", clickHandler);
        > >
        > >
        > > <div id="nav">
        > > <ul>
        > > <li id="l_1">...</li>
        > > ....
        > > </ul>
        > > </div>

        Oops, left out a line:

        function clickHandler(e) {
        var n = YAHOO.util.Event.getTarget(e), id;
        // n could be a child of the li
        for (;;) {
        if (!n || n.id && n.id === "nav") {
        break; // no list item found
        } else if (n.id && n.id.indexOf("l_") > -1) {
        id = n.id;
        break;
        }

        n = n.parentNode;
        }

        alert(id);
        }

        -Adam
      • Michael Heyder
        Thanks, but alert-mess: undefinied ;) Regards Mic ... function clickHandler(e) { var n = YAHOO.util.Event.getTarget(e), id; // n could be a child of the li for
        Message 3 of 5 , Oct 2, 2007
        • 0 Attachment
          Thanks,

          but alert-mess: undefinied ;)

          Regards
          Mic

          Adam Moore <adamoore@...> wrote:
          On Mon, Oct 01, 2007 at 11:41:15PM -0000, rupnaldo wrote:
          > Hi,
          >
          > is there a way to recieve the id of the actual clicked Listelement?
          >
          > function clickHandler( e) {
          > }
          > YAHOO.util.Event. on("nav", "click", clickHandler) ;
          >
          >
          > <div id="nav">
          > <ul>
          > <li id="l_1">... </li>
          > ....
          > </ul>
          > </div>

          function clickHandler( e) {
          var n = YAHOO.util.Event. getTarget( e), id;
          // n could be a child of the li
          for (;;) {
          if (!n || n.id && n.id === "nav") {
          break; // no list item found
          } else if (n.id && n.id.indexOf( "l_") > -1) {
          id = n.id;
          break;
          }
          }

          alert(id);
          }

          -Adam



          Regards,
          Mic

          http://volleyball-portal-duisburg.de
          http://ruposblog.hafenvolleyballer.net
          http://hafenvolleyballer.net


          Be a better Globetrotter. Get better travel answers from someone who knows.
          Yahoo! Answers - Check it out.

        • Adam Moore
          ... Mic, this worked for me, so send a link to your code if you want more help. -Adam
          Message 4 of 5 , Oct 2, 2007
          • 0 Attachment
            On Tue, Oct 02, 2007 at 01:02:42AM -0700, Michael Heyder wrote:
            > Thanks,
            >
            > but alert-mess: undefinied ;)

            Mic, this worked for me, so send a link to your code if you
            want more help.

            -Adam
          Your message has been successfully submitted and would be delivered to recipients shortly.