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

Re: [ydn-javascript] custom object scope in YAHOO.util.Event.addListener

Expand Messages
  • Andy Crain
    Hi Matt, ... That seems the best option (using four arguments, omitting the fifth), but I was hoping to use the fifth arg so that this in the handler would
    Message 1 of 8 , Mar 19, 2006
      Hi Matt,

      On 3/19/06, Matt Vanderpol <matt@...> wrote:
      Andy,

      You can do it without cluttering up customObj:          

      YAHOO.util.Event.addListener('myelementid', 'click', callback, customObj);
      function callback(e, el) {
      // "e" is the event
      // "el" is a reference to customObj
      // "this" is the element that triggered the event - with id myelementid in this case
      }

      -Matt

      That seems the best option (using four arguments, omitting the fifth), but I was hoping to use the fifth arg so that "this" in the handler would reference the customObj.
      Andy
    Your message has been successfully submitted and would be delivered to recipients shortly.