Re: [jQuery] .each backwards ?

2006-10-06 Thread Blair Mitchelmore
I propose hcae: jQuery.fn.hcae = function( fn, args ) { return jQuery.hcae( this, fn, args ); }; jQuery.hcae = function( obj, fn, args ) { if ( obj.length == undefined ) for ( var i in obj ) fn.apply( obj[i], args || [i, obj[i]] ); e

Re: [jQuery] .each backwards ?

2006-10-06 Thread Ⓙⓐⓚⓔ
interesting! When would length be undefined on an JQ object? When I first saw the question, I thought of tail recursion, does JS deal well (optimize) tail recursion? On 10/6/06, Blair Mitchelmore <[EMAIL PROTECTED]> wrote: > I propose hcae: > > jQuery.fn.hcae = function( fn, args ) { > r

Re: [jQuery] .each backwards ?

2006-10-06 Thread Matt Stith
i know js 1.2 does, but i think its only supported in ff 2.0 currently... but dont quote me on that. On 10/6/06, Ⓙⓐⓚⓔ <[EMAIL PROTECTED]> wrote: > interesting! > > When would length be undefined on an JQ object? > > When I first saw the question, I thought of tail recursion, does JS > deal well (o

Re: [jQuery] .each backwards ?

2006-10-06 Thread Dossy Shiobara
On 2006.10.06, Blair Mitchelmore <[EMAIL PROTECTED]> wrote: > I propose hcae: Oh, god no. I see the smiley so I'm guessing you're only kidding, but before someone goes "yeah, that's a good idea ..." > kenton.simpson wrote: > > Is there a way to make .each walk backwards threw the element collect

Re: [jQuery] .each backwards ?

2006-10-06 Thread Ⓙⓐⓚⓔ
ff2,0 is up to js1.7 On 10/6/06, Matt Stith <[EMAIL PROTECTED]> wrote: > i know js 1.2 does, but i think its only supported in ff 2.0 > currently... but dont quote me on that. > > On 10/6/06, Ⓙⓐⓚⓔ <[EMAIL PROTECTED]> wrote: > > interesting! > > > > When would length be undefined on an JQ object? >

Re: [jQuery] .each backwards ?

2006-10-07 Thread Michael Geary
> From: Dossy Shiobara > > I'm surprised there's no .reverse(). i.e.: > > $(collection).reverse().each(...) Great idea! How about the world's smallest plugin: jQuery.fn.reverse = [].reverse; Try it out at http://jquery.com/ by entering these lines into the FireBug console: jQuery.fn.

Re: [jQuery] .each backwards ?

2006-10-07 Thread Jörn Zaefferer
Michael Geary schrieb: >> From: Dossy Shiobara >> >> I'm surprised there's no .reverse(). i.e.: >> >> $(collection).reverse().each(...) >> > > Great idea! > > How about the world's smallest plugin: > >jQuery.fn.reverse = [].reverse; > That's some really great stuff! It took me some ti

Re: [jQuery] .each backwards ?

2006-10-07 Thread kenton.simpson
Thanks for the Idea. This works jQuery.fn.reverse = function() { this.pushStack(this.get().reverse()); return this; } a long that thread a lot more resorting function may be useful. -- View this message in context: http://www.nabble.com/.each-backwards---tf2399145.html#a6693603 Sent from th

Re: [jQuery] .each backwards ?

2006-10-07 Thread Jörn Zaefferer
kenton.simpson schrieb: > Thanks for the Idea. This works > > jQuery.fn.reverse = function() { > this.pushStack(this.get().reverse()); > return this; > } > Nice. That is a better approach then just doing jQuery.fn.reverse = [].reverse. -- Jörn __

Re: [jQuery] .each backwards ?

2006-10-07 Thread John Resig
> jQuery.fn.reverse = function() { > this.pushStack(this.get().reverse()); > return this; > } Huh, at first I though that that code would infinitely recurse, I totally forgot that .get() returns a "clean" array of elements - good call! Just a quick simplification: jQuery.fn.reverse = function()

Re: [jQuery] .each backwards ?

2006-10-07 Thread Jörn Zaefferer
Hi John! > jQuery.fn.unshift = jQuery.fn.unshift; > What is that supposed to do? -- Jörn ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/

Re: [jQuery] .each backwards ?

2006-10-07 Thread kenton.simpson
I agree, do you think .sort() and .reverse() could be added to core jQuery object in the future, or should I just add a plugin. -- View this message in context: http://www.nabble.com/.each-backwards---tf2399145.html#a6694292 Sent from the JQuery mailing list archive at Nabble.com.

Re: [jQuery] .each backwards ?

2006-10-07 Thread Michael Geary
> > From: Michael Geary > > > > Armed with this knowledge, one might be tempted to load > > all the Array methods in one fell swoop: > > > >jQuery.fn.prototype = Array.prototype; > > > > But that does not work, presumably because jQuery is > > already being a bit sneaky about its Array-like be

Re: [jQuery] .each backwards ?

2006-10-07 Thread Michael Geary
> > jQuery.fn.reverse = function() { > >this.pushStack(this.get().reverse()); > >return this; > > } > Nice. That is a better approach then just doing > jQuery.fn.reverse = [].reverse. I'm curious, what is the advantage of one approach over the other? -Mike

Re: [jQuery] .each backwards ?

2006-10-07 Thread John Resig
On 10/7/06, Michael Geary <[EMAIL PROTECTED]> wrote: > > > jQuery.fn.reverse = function() { > > >this.pushStack(this.get().reverse()); > > >return this; > > > } > > > Nice. That is a better approach then just doing > > jQuery.fn.reverse = [].reverse. > > I'm curious, what is the advantage o

Re: [jQuery] .each backwards ?

2006-10-07 Thread John Resig
Oops, I meant to make that: jQuery.fn.unshift = jQuery.fn.add; The issue is, however, that fundamentally .push() or .unshift() won't work as expected, since adding an item to a jQuery object isn't like adding a item to a normal array. The jQuery object is more like a 'Set' than it is a true 'Array

Re: [jQuery] .each backwards ?

2006-10-07 Thread John Resig
> I agree, do you think .sort() and .reverse() could be added to core jQuery > object in the future, or should I just add a plugin. Sort, reverse, and splice are definitely possible - maybe for the 1.1 release. --John ___ jQuery mailing list discuss@jq