I have defined a new function on the Element namespace:

    //common function to switch tabs
      setTab: function(elm, evt){
        //hide all the content

It works perfectly when it's passed from an element


But if I want to register a click handler on all the tabs:

        tabs.invoke('observe','click', setTab);

I get an error:

TypeError: 'undefined' is not a function (evaluating 'handler.call(element, 

...from Prototype 1.7 in Safari 5.1.2.

Is there a way to write this so it will work in both contexts, or do I need to 
add an explicit event handler form of the method somewhere else?

If I write the handler like this:

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

...then it works perfectly, but I'm confused why it's not working in the other 
syntax. I could swear I've used that same construction earlier and had it work 
just fine.

Thanks in advance,


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 
For more options, visit this group at 

Reply via email to