Gents, I have what I thought was a simple scenario, but IE seems to have found a way to make it difficult: I am creating pairs of drop-downs of times of the day (9:00, 9:15, ...) on the fly (using AJAX) and want to be able to adjust the displayed difference between them in hours onChange and store this information in a global hash. Straightforwardly enough, I simple use Event.observe to set up an anonymous function to look for changes and then hand off to another function to update both the hours displayed and those stored in the hash. This works fine in Firefox. BUT, in IE7-Vista (at least), the function called by my anonymous listener function does not seem to have access to the global variables (and neither does my anonymous function, as revealed by the tried and true ''alert'' test). My global hash is undefined when I try to write to it. Is this something anyone out there has seen before? Thanks, Caritj --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey there, I think your best shot at getting an efficient answer here is to post a minimal online demo of your issue. BTW, does this also affect IE6 or other browsers? -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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''m afraid that most minimal demo I can write that adequately demonstrates this is a few pages long. (Though, if it is necessary, I will gladly post it). But, perhaps I can narrow this down somewhat: the problem occurs in the event fired by onChange or onClick of a select list - but onBlur works fine! (I am not yet in a position to test on other browsers, but I can reiterate that it does not affect Firefox). Anyone out there run into this before? On Feb 23, 3:17 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> Hey there, > > I think your best shot at getting an efficient answer here is to post a > minimal online demo of your issue. > > BTW, does this also affect IE6 or other browsers? > > -- > Christophe Porteneuve a.k.a. TDD > "[They] did not know it was impossible, so they did it." --Mark Twain > Email: t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Okay. The plot thickens. What I said before was incorrect - onBlur works no better. But, when I navigate away, or close the browser and visit the page fresh, everything works fine. It is only after a reload that I have trouble. So, to consolidate: my global variable becomes undefined when I access it through an anonymous listener function attached through Event.observe IN IE7 only after reloading the page. Behavior seems correct when I am visiting the page for the first time, or when I navigate away and then some back. Weird, eh? On Feb 23, 10:02 am, "caritj" <car...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m afraid that most minimal demo I can write that adequately > demonstrates this is a few pages long. (Though, if it is necessary, I > will gladly post it). But, perhaps I can narrow this down somewhat: > the problem occurs in the event fired by onChange or onClick of a > select list - but onBlur works fine! (I am not yet in a position to > test on other browsers, but I can reiterate that it does not affect > Firefox). > > Anyone out there run into this before? > > On Feb 23, 3:17 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote: > > > Hey there, > > > I think your best shot at getting an efficient answer here is to post a > > minimal online demo of your issue. > > > BTW, does this also affect IE6 or other browsers? > > > -- > > Christophe Porteneuve a.k.a. TDD > > "[They] did not know it was impossible, so they did it." --Mark Twain > > Email: t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
This may not be entirely related to your problem, but based on your symptoms, it something worth considering. Several browsers try to be "helpful" when you refresh a page, and prepopulate the value selected before the refresh--even if it''s not the value marked in HTML as the default selected value. (i.e. it may not default to the option found at <option selected="selected">foo</ option>) IIRC, Firefox exhibited this behavior. I had to get around it w/ an onload handler to reset appropriate fields. YMMV TAG On Feb 23, 2007, at 8:15 AM, caritj wrote:> > Okay. The plot thickens. What I said before was incorrect - onBlur > works no better. But, when I navigate away, or close the browser and > visit the page fresh, everything works fine. It is only after a reload > that I have trouble. > > So, to consolidate: my global variable becomes undefined when I access > it through an anonymous listener function attached through > Event.observe IN IE7 only after reloading the page. Behavior seems > correct when I am visiting the page for the first time, or when I > navigate away and then some back. > > Weird, eh? > > On Feb 23, 10:02 am, "caritj" <car...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> I''m afraid that most minimal demo I can write that adequately >> demonstrates this is a few pages long. (Though, if it is necessary, I >> will gladly post it). But, perhaps I can narrow this down somewhat: >> the problem occurs in the event fired by onChange or onClick of a >> select list - but onBlur works fine! (I am not yet in a position to >> test on other browsers, but I can reiterate that it does not affect >> Firefox). >> >> Anyone out there run into this before? >> >> On Feb 23, 3:17 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote: >> >>> Hey there, >> >>> I think your best shot at getting an efficient answer here is to >>> post a >>> minimal online demo of your issue. >> >>> BTW, does this also affect IE6 or other browsers? >> >>> -- >>> Christophe Porteneuve a.k.a. TDD >>> "[They] did not know it was impossible, so they did it." --Mark >>> Twain >>> Email: t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Gents, Thanks for all your help, but I''m afraid, as is often the case, that this was my fault. I was assigning the variable to the value returned by a void function. But because, I suppose, that function itself was assigning to the global internally, it resulted in the very weird symptoms I described - sometimes it was defined, sometimes not. Be warned... :) Thanks, Paul --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hey there, Are you seriously saying you don''t understand why explicitly reloading a page erases all previously defined "global" variables?! I hope not. Because there IS NO global variable in JS. There are only page-scope variables. And they exist for the page''s lifetime only, (client-side speaking, of course). So when you navigate and go back, your browser "restores" the page''s scripting context (which is often part of its in-memory short-term history storage), but when you explicitely reload, you''re effectively asking it to behave as if opening the page for the first time in its session/cache. This is a brand new scripting context. If I did understand correctly the behavior model you described, then it''s entirely nominal. -- Christophe Porteneuve aka TDD tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 24, 4:14 am, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> Hey there, > > Are you seriously saying you don''t understand why explicitly reloading a > page erases all previously defined "global" variables?! > > I hope not. Because there IS NO global variable in JS.I wouldn''t say that - ECMAScript (javascript) certainly *does* have global variables. The non-persistance of globals across documents is a host (browser) feature, it has nothing to do with the language per se. It is required in a browser for security and makes javascript easier to program with - memory management is vastly simplified.> There are only > page-scope variables. And they exist for the page''s lifetime only, > (client-side speaking, of course). So when you navigate and go back, > your browser "restores" the page''s scripting context (which is often > part of its in-memory short-term history storage), but when you > explicitely reload, you''re effectively asking it to behave as if opening > the page for the first time in its session/cache. This is a brand new > scripting context.Absolutely. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---