I'm fairly certain that in Prototype 1.5.0_rc0 and up, you just have
to call Element.addMethods(). The
Object.extend(Element,Element.Methods); is redundant. Every time
Element.addMethods() is called, all elements accessed via $() (or any
other prototype specific element selector (like Event.element(event),
etc) all will have their own methods applied as well as any methods
you've provided via Element.addMethods()
My example:
Element.addMethods({
visible: function(element) {
return $(element).getStyle('display') == 'none' ? false : true;
}
});
That's all it takes in our scripts to have the visible() method of an
element be overwritten to actually use the getStyle() method instead
of the manual .style.display attribute.
-E
On 11/28/06, Marius Feraru <[EMAIL PROTECTED]> wrote:
>
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Ionut Cioflan wrote:
> > Object.extend(Element, {
> > getWidth: function(element) {
> > [...]
> > });
> > Questions:
> > 1. Have I done something wrong or the extend function doesn't working
> > properly ?
> > 2. Why aren't these functions added by default to Element (only
> > getHeight() exists) ?
>
> This is the proper way to add your own methods:
>
> Element.addMethods({
> [your methods here]
> });
> Object.extend(Element, Element.Methods);
> Element.addMethods();
>
> cheers
> - --
> Marius Feraru
> -----BEGIN PGP SIGNATURE-----
>
> iD8DBQFFbOOAtZHp/AYZiNkRAqYJAKCqsuakBO3vVZOB7KUSWRxACsuLyACfaz+H
> oSz4NKvkaHgTgvfBqzLq7rs=
> =LkzL
> -----END PGP SIGNATURE-----
>
> >
>
--
Eric Ryan Harrison, Developer
model13 Designs
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" 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/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---