mcrawford-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-28 18:29 UTC
Extra parameters into function with .each()?
I have a function that is essentially:
function(xArray, y) {
xArray.each(function(x) {
// I need y in here!
});
}
Probably I''m using the wrong method of going about this, but is there
a way to pass y into that function inside of the .each()? Basically,
is there a way to get extra parameters into that function inside of
the .each. Or of course if there is a better way without .each(), let
me know! Thanks.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
Manu Temmerman-Uyttenbroeck
2008-Feb-29 05:32 UTC
Re: Extra parameters into function with .each()?
This doesn''t work?
function(xArray, y) {
xArray.each(function(x) {
alert(y);
});
}
If that doesn''t work, then try:
function(xArray, y) {
var _y = y;
xArray.each(function(x) {
alert(_y);
});
}
On Thu, Feb 28, 2008 at 7:29 PM,
mcrawford-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
<mcrawford-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
wrote:
>
> I have a function that is essentially:
>
> function(xArray, y) {
> xArray.each(function(x) {
> // I need y in here!
> });
> }
>
> Probably I''m using the wrong method of going about this, but is
there
> a way to pass y into that function inside of the .each()? Basically,
> is there a way to get extra parameters into that function inside of
> the .each. Or of course if there is a better way without .each(), let
> me know! Thanks.
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Spinoffs" group.
To post to this group, send email to
rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---
mcrawford-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Feb-29 16:36 UTC
Re: Extra parameters into function with .each()?
Thanks for the reply, and yes, you''re right, the first approach does work. I actually removed the original message from the board because I realized that my mistake was in another function that was calling this one. I thought I removed it quickly enough but maybe that wasn''t a good idea. It was a dumb question in the first place and I should have spent more time debugging before posting. Thanks, though. On Feb 28, 9:32 pm, "Manu Temmerman-Uyttenbroeck" <manu.temmermanuyttenbro...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> This doesn''t work? > function(xArray, y) { > xArray.each(function(x) { > alert(y); > }); > > } > > If that doesn''t work, then try: > function(xArray, y) { > var _y = y; > xArray.each(function(x) { > alert(_y); > });} > > On Thu, Feb 28, 2008 at 7:29 PM, mcrawf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org <mcrawf...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> > wrote: > > > > > I have a function that is essentially: > > > function(xArray, y) { > > xArray.each(function(x) { > > // I need y in here! > > }); > > } > > > Probably I''m using the wrong method of going about this, but is there > > a way to pass y into that function inside of the .each()? Basically, > > is there a way to get extra parameters into that function inside of > > the .each. Or of course if there is a better way without .each(), let > > me know! Thanks.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Many of us never interact with the Web form of this mailing list. The moment you post something, an e-mail is sent to the mailing list. That''s the only message I see, and no, you may not edit my in-box! Walter On Feb 29, 2008, at 11:36 AM, mcrawford-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org wrote:> > I actually removed the original message from the board because > I realized that my mistake was in another function that was calling > this one.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---