Isn't that what $.map does ?

--
Ariel Flesler
http://flesler.blogspot.com

On Dec 17, 6:14 pm, "Anton Backer" <[email protected]> wrote:
> It feels more natural if the return value of $.each would be the value
> returned from the callback. I wrote the following plugin, running into
> a dead end as soon as i realized that i don't have the callback's
> return value:
>
> $.fn.eachgroup = function(prop, cb)
> {
>        var col = {}, null_ = [], undefined_ = [];
>        this.each(function()
>        {
>                var val = this[prop];
>                var target =
>                        val === null ? null_ :
>                        val === undefined ? undefined_ :
>                        (col[val] = col[val] || []);
>                target.push(this);
>        });
>        $.each(col, cb);
>        // these two should not execute if cb ever returns 'false'
>        if (null_.length) cb(null, null_);
>        if (undefined_.length) cb(undefined, undefined_);
>        return this;
>
> };
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to