Eric,
I need to implement a simliar funcnality, and was looking at the trac. What
throws me offis that thetatus of the Bug was set to 'review' a few hours
ago.
Any *more* magical way to do this coming up?
Erik Beeson wrote:
>
> Even easier than that:
>
> jQuery.fn.sort = function() {
> return this.pushStack( jQuery.makeArray( [].sort.apply( this,
> arguments )) );
> };
>
> See here: http://dev.jquery.com/ticket/255
>
> Looks like I'm still about the only person that actually uses this.
>
> --Erik
>
>
> On 3/26/07, Luke Lutman <[EMAIL PROTECTED]> wrote:
>> I'd guess it's because arguments isn't really an array (it has a length
>> property, but none of
>> Array's methods).
>>
>> Something like this might do the trick:
>>
>> jQuery.fn.sort = function() {
>> for(var i = 0, args = []; i < arguments.length; i++)
>> args.push(i);
>> return this.pushStack( [].sort.apply( this, args ), []);
>> };
>>
>> Luke
>>
>>
>> Bruce McKenzie wrote:
>> > There was a thread on this list in October which indicates (if I read
>> it
>> > right) that I ought to be able to rearrange some paragraphs as follows:
>> >
>> > <script type="text/javascript">
>> >
>> > $(function(){
>> >
>> > jQuery.fn.sort = function() {
>> > return this.pushStack( [].sort.apply( this, arguments ), []);
>> > };
>> >
>> > $("p.items").sort(function(a,b){
>> > return a.innerHTML > b.innerHTML ? 1 : -1;
>> >
>> > }).appendTo("#Foo");
>> >
>> > });
>> > </script></head>
>> > <body>
>> >
>> > <div id='Foo'>
>> > <p class='items'>C</p>
>> > <p class='items'>B</p>
>> > <p class='items'>A</p>
>> > </div>
>> >
>> > </body>
>> > </html>
>> >
>> > But this error results:
>> > error: second argument to Function.prototype.apply must be an array
>> >
>> > Is it me -- or does the sort function need to be adjusted for jQuery
>> > 1.1.1 (and how would a person do that :-) ?
>> >
>>
>>
>> --
>> zinc Roe Design
>> www.zincroe.com
>> (647) 477-6016
>>
>> _______________________________________________
>> jQuery mailing list
>> [email protected]
>> http://jquery.com/discuss/
>>
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
View this message in context:
http://www.nabble.com/Sorting-items-in-jQuery-pseudo-array-tf3466978.html#a9688290
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/