Try to get everything in the form, do a loop, and the first one that's
an input, or select or whatever, is your match?

On Sep 22, 12:16 am, Jan Kassens <[EMAIL PROTECTED]> wrote:
> hmm, you guys made me pondering and i asked in the dev channel, but a  
> better solution than adding a class to your form fields and get them  
> with document.getElement('.formFieldClass'); didn't pop up.
>
> .getFirst get the first child that matches the selector (it goes down  
> to firstChild and than tests all nextSibling until one matches) so  
> that wont work either.
>
> .match() is supposed to work with single selectors like  
> "div.foo.bar[size=20]" etc (no "ul > li", or "div, p")
>
> - jan
>
> On Sep 21, 2008, at 23:53, Guillermo Rauch wrote:
>
>
>
> > As I suggested originally, getFirst should return what you expect,  
> > since it definitely works differently from getElement.
>
> > getFirst makes use of Element.match. Basically it walks the dom tree  
> > till "input, select, textarea" match.
>
> > getElement, as you said, splits the selector by finding ',' and  
> > processes each separately, thus retrieving
> > all inputs, all selects and all textareas.
>
> > I've looked into MooTools code and it seems Element.match() won't  
> > match a select tag if the selector is "input, select, textarea", but  
> > it'll
> > match an input with the same selector.
>
> > This might be a bug, please report it.
>
> > Testcase:
>
> > <body>
> >     <select name="select1" id="select1">
> >       <option value="option1">option1</option>
> >       <option value="option2">option2</option>
> >     </select>
>
> >     <input type="text" name="input1" value="" id="input1" />
>
> >     <textarea name="textarea1" id="textarea1" rows="8" cols="40"></
> > textarea>
> > </body>
>
> > var Playground = {
>
> >   init: function() {
> >     console.log($(document.body).getElement('input, select,  
> > textarea').get('tag')); // input expected
> >     console.log($(document.body).getFirst('input, select,  
> > textarea').get('tag')); // select expected
> >   }
>
> > };
>
> > window.addEvent('domready', function() {
> >   Playground.init();
> > });
>
> > On Sun, Sep 21, 2008 at 5:58 PM, kesmit <[EMAIL PROTECTED]>  
> > wrote:
>
> > That still doesn't work though because if you use multiple selectors
> > in the argument to getElement (e.g., "input, select, textarea"), it
> > will create a list of all of the first elements (i.e., input), then
> > add to that a list of the next elements (i.e., select), and so on.  So
> > even if a select element occurs before the first input element in the
> > document, getElement will still return the input element.
>
> > On Sep 20, 7:09 pm, horseweapon <[EMAIL PROTECTED]> wrote:
> > > passing a selector to getFirst() is equivalent to using  
> > getElement();
>
> > > try $(document.body).getElement('...');
>
> > > I've done that before and it worked. Wrapping document.body in a $()
> > > function is for IE which does not extends elements with mootools
> > > functions if they are not grabbed with $(); Same thing with $
> > > (event.target) (so usefull)
>
> > --
> > Guillermo Rauch
> >http://devthought.com
>
> --
> my blog:http://blog.kassens.net

Reply via email to