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

removeListener

Expand Messages
  • Darek Adamkiewicz
    Hi According to docs: http://developer.yahoo.com/yui/docs/YAHOO.util.Event.html#method_removeListener removeListener should return true if the unbind was
    Message 1 of 1 , May 3, 2009
    View Source
    • 0 Attachment
      Hi
      According to docs:
      http://developer.yahoo.com/yui/docs/YAHOO.util.Event.html#method_removeListener

      removeListener should return
      "true if the unbind was successful, false otherwise"

      while in the following case (see below) it returns 'undefined' anyway
      i.e. whether or not listener was previously removed.

      Regards
      Darek


      <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
      <html>
      <head>
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <title></title>

      <style type="text/css">
      body {
      margin:0;
      padding:0;
      }
      </style>
      <!-- js -->
      <script type="text/javascript" src="http://yui.yahooapis.com/2.7.0/build/yahoo-dom-event/yahoo-dom-event.js"></script>
      </head>
      <body>
      <div id="a1">click here to display</div>
      <div id="a2">to remove listener click here</div>
      <script type="text/javascript">
      YAHOO.util.Event.addListener("a1", "click",
      function(ev) {
      var el = YAHOO.util.Event.getTarget(ev);
      alert(el.id + " was clicked");
      }
      );
      YAHOO.util.Event.addListener("a2", "click",
      function(ev) {
      var result = YAHOO.util.Event.removeListener("a1", "click");
      alert("listener was removed? " + result);
      }
      );
      </script>
      </body>
      </html>
    Your message has been successfully submitted and would be delivered to recipients shortly.