I have defined a new function on the Element namespace:

    //common function to switch tabs
    Element.addMethods({
      setTab: function(elm, evt){
        //hide all the content
        bodies.invoke('hide');
        tabs.invoke('removeClassName','active');
        elm.addClassName('active').bodies.invoke('show');
      }
    })

It works perfectly when it's passed from an element

        $('sometab').setTab();

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, 
event)')

...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,

Walter

-- 
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 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to