Re: [jQuery] break in $.each

2007-01-05 Thread Aaron Heimlich
On 1/5/07, Jörn Zaefferer [EMAIL PROTECTED] wrote: Thats intersting. Could you please file this as a bug report (component docs)? Thanks. Done! http://jquery.com/dev/bugs/bug/754/ -- Aaron Heimlich Web Developer [EMAIL PROTECTED] http://aheimlich.freepgs.com

[jQuery] break in $.each

2007-01-04 Thread Andreas Wahlin
Is there a way to break the $.each loops? I'd like it to be $.each(object, function() { break; }); but it doesen't seem so. Andreas ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/

Re: [jQuery] break in $.each

2007-01-04 Thread Klaus Hartl
Andreas Wahlin schrieb: Is there a way to break the $.each loops? I'd like it to be $.each(object, function() { break; }); but it doesen't seem so. Andreas ___ jQuery mailing list discuss@jquery.com http://jquery.com/discuss/

Re: [jQuery] break in $.each

2007-01-04 Thread Sam Collett
On 04/01/07, Klaus Hartl [EMAIL PROTECTED] wrote: Andreas Wahlin schrieb: Is there a way to break the $.each loops? I'd like it to be $.each(object, function() { break; }); but it doesen't seem so. Andreas ___ jQuery

Re: [jQuery] break in $.each

2007-01-04 Thread Mike Alsup
Also, why does a string get returned as an array instead of a string? I think that's just a firebug thing. It sees that the object has a length prop and treats it like an array. But more interesting is that your test did not produce the expected results.

Re: [jQuery] break in $.each

2007-01-04 Thread Michael Geary
Done a test (requires Firebug - or Firebug lite (which I presume would also work)). var foo = [one, 2, three, new Date()]; $.each(foo, function() { if(this === 2) return false; console.log(typeof this); } ) This logs: [o, n, e] 2

Re: [jQuery] break in $.each

2007-01-04 Thread Michael Geary
Would you like an Array iterator that works the way you'd expect? Here is a simple one: Array.prototype.each = function( yields ) { for( var i = 0, n = this.length; i n; i++ ) { if( yields( this[i], i ) === false ) break; } };

Re: [jQuery] break in $.each

2007-01-04 Thread Jörn Zaefferer
Klaus Hartl schrieb: Andreas Wahlin schrieb: Is there a way to break the $.each loops? I'd like it to be $.each(object, function() { break; }); but it doesen't seem so. Andreas ___ jQuery mailing list discuss@jquery.com

Re: [jQuery] break in $.each

2007-01-04 Thread Michael Geary
Andreas, if I remember correctly, the following should work: $.each(object, function() { return false; }); That isn't supported. The necessary code was removed due to unsolved problems. Actually the stuff that Michael just posted would help a lot to solve it, though I'm not

Re: [jQuery] break in $.each

2007-01-04 Thread Jörn Zaefferer
Michael Geary schrieb: The code I posted does solve this problem completely - simply use objectEach instead of $.each, and change your callback function to take explicit parameters instead of using this. Using this in an object iterator doesn't make much sense anyway. You need two arguments

Re: [jQuery] break in $.each

2007-01-04 Thread Aaron Heimlich
I just took a look at the code for $.each and noticed that is passes two arguments to the callback, the name/index of the current item and the item itself (in that order). Test page: http://aheimlich.freepgs.com/tests/jquery/each-test/ On 1/4/07, Michael Geary [EMAIL PROTECTED] wrote:

Re: [jQuery] break in $.each

2007-01-04 Thread Yehuda Katz
Aaron: That's correct and it can be extremely useful in DOM manipulation if you need to build unique strings based on the object (say, ids). -- Yehuda On 1/4/07, Aaron Heimlich [EMAIL PROTECTED] wrote: I just took a look at the code for $.each and noticed that is passes two arguments to the