If you just bind your observer to the current instance of "this" when
you are setting up your observer, everything will work fine. Here is a
contrived example to illustrate usage.

// this code is untested
var Foo = {
  initialize: function(){
    this.message = 'I am who I say I am';
    this.body = document.body;
    // attach to a normal method
    this.body.observe('click', this.bodyClicked.bindAsEventListener(this));

    // attach to an anonymous method
    this.body.observe('keypress', function(event){
      alert('you pressed a key, here is my message: ' + this.message);
    }.bindAsEventListener(this));
  },
  bodyClicked: function(event){
    alert('you clicked on my body, here is my message: ' + this.message);
  }
};

Foo.initialize();

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to