I don't see any binding going on, so I think you have to be very
careful with your use of the term "this". In your second example:

tabs.invoke('observe','click', function(evt){ this.setTab(); } );

The term "this" refers to the element, so it works. When you invoke
"this.setTab()", you have given the full context and the program knows
what you're referring to. When you just write "setTab", the program
doesn't know what you're referring to. There is no global function
named "setTab", it is only in the context of the element that the
method exists.

Take a look at this example:

var myClass = new Class({
   initialize: function(){
      this.tabs = $('.sometab');
      this.tabs.invoke('observe', 'click', this.setTabs.bind(this));
   },

   setTabs: function(event){
      /*  THE KEYWORD this REFERS TO myClass IN THIS CONTEXT */
      var target = event.target;
      target.setTab();
   }
}

When someone clicks on a tab the method "setTabs" is invoked which in
turn executes the method "setTab" on the target element.

I hope that was helpful

-- 
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 [email protected].
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