Situation & problem: I''m returning a lot of pure javascript in my responses and I have one particular case where I''d like the headers to remain "application/ javascript", but for Prototype to NOT automatically evaulate the code, and just provide it to me so I can eval it myself? Reason being: I''ve noticed that when prototypes Ajax.Request auto-evals, it does it at the highest point in the scope chain, rather than where it was instantiated. An alternate solution: Maybe there''s a way of controlling the scope of the automatic eval prototype does? Thanks a lot, and keep up the spect"acul"(ous)ar work! --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
> Situation & problem: > > I''m returning a lot of pure javascript in my responses and I have one > particular case where I''d like the headers to remain "application/ > javascript", but for Prototype to NOT automatically evaulate the code, > and just provide it to me so I can eval it myself?That''s planned (see http://dev.rubyonrails.org/ticket/8391)> Reason being: > > I''ve noticed that when prototypes Ajax.Request auto-evals, it does it > at the highest point in the scope chain, rather than where it was > instantiated. > > An alternate solution: > Maybe there''s a way of controlling the scope of the automatic eval > prototype does?Partially. If you want to set things in the global scope do it like so: window.bla = ''foo''; (instead of var bla = ''foo'') --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
No, I DON''T want it to be in global scope. I want it to be in the scope of where I called Ajax.Request. The way auto eval works right now, it can create a lot of scope pollution. Right now, it does make things global. - Omega On Jun 6, 1:41 pm, tobie <tobie.lan...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Situation & problem: > > > I''m returning a lot of pure javascript in my responses and I have one > > particular case where I''d like the headers to remain "application/ > > javascript", but for Prototype to NOT automatically evaulate the code, > > and just provide it to me so I can eval it myself? > > That''s planned (seehttp://dev.rubyonrails.org/ticket/8391) > > > Reason being: > > > I''ve noticed that when prototypes Ajax.Request auto-evals, it does it > > at the highest point in the scope chain, rather than where it was > > instantiated. > > > An alternate solution: > > Maybe there''s a way of controlling the scope of the automatic eval > > prototype does? > > Partially. If you want to set things in the global scope do it like > so: > > window.bla = ''foo''; (instead of var bla = ''foo'')--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I''ve created a ticket for this... Take a look at the example I included, it makes everything fairly clear. http://dev.rubyonrails.org/ticket/8595 - Omega --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I saw Tobie''s comments on the ticket. It looks like you may want to study a bit of how Javascript handles scoping. You may also find it useful to study Prototype''s bind() function. http://prototypejs.org/api/function TAG On Jun 6, 2007, at 2:50 PM, Omega wrote:> > I''ve created a ticket for this... Take a look at the example I > included, it makes everything fairly clear. > > http://dev.rubyonrails.org/ticket/8595 > > - Omega > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I know how javascript scope works, I don''t need to be "educated" on it. I work with closures every day of my life, so I''m probably well capable of discussing the subject. The fact of the matter is that prototype hijacks the scope and I don''t know where it goes. I think the only thing that can really be done is to just offer the option to disable automatic JS parsing, and do an eval() myself in the scope I''d like. (as eval() normally exists in the scope in which it is called....) - Omega On Jun 6, 8:32 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> I saw Tobie''s comments on the ticket. It looks like you may want to > study a bit of how Javascript handles scoping. > > You may also find it useful to study Prototype''s bind() function. > > http://prototypejs.org/api/function > > TAG > > On Jun 6, 2007, at 2:50 PM, Omega wrote: > > > > > I''ve created a ticket for this... Take a look at the example I > > included, it makes everything fairly clear. > > >http://dev.rubyonrails.org/ticket/8595 > > > - Omega--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Wow. Please forgive my misstep. No insult intended--while you may be extremely competent in the use of closures, scoping, etc., understand that such foundational knowledge is uncommon in those requesting help on this list. However, it seems the intent of your request could be handled through the use of bind(). Understanding of bind has been, in my experience, less common than understanding of closures. If what you''re asking for is not possible with bind(), I wonder whether applying the scoping you''re requesting is possible. In this I defer to some of the more experienced voices here--and Tobie has already suggested it''s not possible. TAG On Jun 7, 2007, at 1:27 PM, Omega wrote:> > I know how javascript scope works, I don''t need to be "educated" on > it. I work with closures every day of my life, so I''m probably well > capable of discussing the subject. > > The fact of the matter is that prototype hijacks the scope and I don''t > know where it goes. > > I think the only thing that can really be done is to just offer the > option to disable automatic JS parsing, and do an eval() myself in the > scope I''d like. > (as eval() normally exists in the scope in which it is called....) > > > - Omega > > On Jun 6, 8:32 pm, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote: >> I saw Tobie''s comments on the ticket. It looks like you may want to >> study a bit of how Javascript handles scoping. >> >> You may also find it useful to study Prototype''s bind() function. >> >> http://prototypejs.org/api/function >> >> TAG >> >> On Jun 6, 2007, at 2:50 PM, Omega wrote: >> >> >> >>> I''ve created a ticket for this... Take a look at the example I >>> included, it makes everything fairly clear. >> >>> http://dev.rubyonrails.org/ticket/8595 >> >>> - Omega > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---