You could even get carried away and turn that into a function called, say,
$$$:
window.$$$ = function() {
var elements = new Elements();
Array.from(arguments).each(function(selector) {
elements.append(document.getElements(selector));
});
return elements;
}
But that's perhaps going a little too far. :P
http://barryvan.com.au/
[email protected]
On Thu, Mar 24, 2011 at 5:58 PM, Barry van Oudtshoorn <
[email protected]> wrote:
> The problem, though Christoph, is that that assumes that the IDs will be
> set so as to be alphabetically sortable... If, Kilian, you need something
> that will just work with the order you request the elements, I think your
> only option is something along the lines of:
>
> var selectors = ['#div1', '#div2', '#div3'];
> var elements = new Elements();
> for (var i = 0; i < selectors.length; i++) {
> elements.append(document.getElements(selectors[i]));
> }
>
> elements.somethingOrOther()
>
> http://barryvan.com.au/
> [email protected]
>
>
>
> On Thu, Mar 24, 2011 at 5:52 PM, Christoph Pojer <
> [email protected]> wrote:
>
>> As said, we just follow the specification, so this is the expected
>> behavior.
>>
>> In your case, this is what you could do:
>>
>> var elements = $$('elements');
>> elements.sort(function(a, b){
>> if (a.id == b.id) return 0;
>> return (a.id > b.id) ? 1 : -1;
>> });
>>
>> That is all.
>>
>
>