It shouldn't be a problem. Calling addMethods without arguments simply
iterates over Element.Methods.* (and family) and adds them to
appropriate DOM elements. c.f.:
http://www.prototypejs.org/api/element/addMethods
P.S.
It might make sense to extend Form.Methods instead of
Form.Element.Methods
myForm.getElements().findAll(Form.Element.Methods.isActive)
// vs
myForm.getActiveFields();
On Feb 6, 1:19 pm, tgmdbm <[EMAIL PROTECTED]> wrote:
> i agree, selectors really only look nicer for simple expressions.
>
> i've got it to myForm.getElements().findAll( activeField )
>
> I was wondering, are there any complications with calling
> Element.addMethods() without arguments again?
>
> I want to add activeField to Form.Element.Methods and have that appear
> when i call $(). The way it works at the moment is there's a call to
> Element.addMethods() at the very end of prototype.js, would it cause
> problems if i called it again?
>
> thanks
>
> On Feb 6, 9:13 am, Christophe Porteneuve <[EMAIL PROTECTED]> wrote:
>
> > Hey,
>
> > If you look into CSS3 carefully you'll see the selector for your needs
> > is actually longer than your custom findAll call. It would probably go
> > something like this (wrapped/indented for this e-mail):
>
> > var fields =
> > yourForm.select('select:not(:disabled),textarea:not(:disabled),
> > input:not(:disabled)[type!=hidden][type!=button][type!=submit]');
>
> > Quite a mouthful. I'm not at all sure it makes for "sweeter syntax"
> > than a custom filter:
>
> > var fields = yourForm.getElements().findAll(function(e) {
> > return !e.disabled && !'hidden button submit'.include(e.type);
>
> > });
>
> > As for performance comparisons, I'm also confident the custom filter
> > will be way faster on one-shot uses or non-XPath contexts.
>
> > 'HTH
>
> > --
> > Christophe Porteneuve aka TDD
> > [EMAIL PROTECTED]
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---