Hi,

Closures is something that (can) cause memory leaks, right?
kangax, would you mind explaining in a bit more detail why you wrote the
code like you wrote it? I'm a bit lost in it. I restructured the code you
wrote a bit... http://pastie.caboo.se/156248
- Is there a reason why you don't write a ';' after the new Ajax.Request
(...)?
- Is there a reason why you don't write a ';' after the
someArray.each(function(item)
{ ... })?
- I'm getting lost in how you constructed the onSuccess callback...

Thx...

Manu.

On Fri, Feb 22, 2008 at 11:11 PM, kangax <[EMAIL PROTECTED]> wrote:

>
> Looks like a closure issue to me (solved with another closure).
> Also, is that an array you are iterating over using "for..in" ?
>
> siteListArray.each(function(item) {
>  var url = 'functions.php?command=numberOfErrors&site=' + item;
>  new Ajax.Request(url, {
>    onSuccess: (function(item) { return function(t) {
>      $('sidebar_site_div_' + item).update(t.responseText);
>    }})(item)
>  })
> })
>
> - kangax
>
> On Feb 22, 4:02 pm, Chach <[EMAIL PROTECTED]> wrote:
> > Hi everybody,
> >
> > I'm just getting kicked off on prototype and I'm having a problem that
> > I'm hoping to get some help on..  I've had good success with
> > Ajax.Updater, but now I'm trying to use Ajax.Request with the use of
> > its callback abilities.  My issue is that I'm trying to get a hold of
> > one of the Element objects in the DOM using $('element'), however the
> > name of the element can vary and so I have to assemble the name using
> > the value in an array.  It's almost like the siteListArray[x] does not
> > work in the callback.  Is it possible that the callback cannot see a
> > variable that was declared earlier in my code at a global scope?
> > Thanks in advance.
> >
> > for (x in siteListArray)
> > {
> >         var url = 'functions.php?command=numberOfErrors&site=' +
> > siteListArray[x];
> >         new Ajax.Request(url, {
> >                 asynchronous:true,
> >                 onComplete: function(transport) {
> >                         $('sidebar_site_div_' +
> > siteListArray[x]).update(transport.responseText);
> >                 }
> >         });
> >
> > }
> >
>

--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to