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