> Yeah, I had suggested returning an explicit false from your 
> each function should short circuit.  It was an easy add to 
> the jquery source too, but I believe jq 1.0 is in feature 
> freeze at the moment.

You can easily implement this yourself. Here is the code for each() from
svn:

   each: function( obj, fn, args ) {
      if ( obj.length == undefined )
         for ( var i in obj )
            fn.apply( obj[i], args || [i, obj[i]] );
      else
         for ( var i = 0; i < obj.length; i++ )
            fn.apply( obj[i], args || [i, obj[i]] );
      return obj;
   },

Beware of untested code, but this plugin (for the svn version) should change
each() to stop the loop on a false return:

   jQuery.each = function( obj, fn, args ) {
      if ( obj.length == undefined ) {
         for ( var i in obj )
            if( fn.apply( obj[i], args || [i, obj[i]] ) === false )
               break;
      }
      else {
         for ( var i = 0; i < obj.length; i++ )
            if( fn.apply( obj[i], args || [i, obj[i]] ) === false)
               break;
      }
      return obj;
   };

-Mike


_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to