I am having a very hard time debugging this. I have a form that I inject into the page using Ajax Updater, and submit using Ajax.Request. If the form is successful, I want to then insert the form content into an UL, but if it''s not correct, I need to update a different div (the one the form was initially injected into) with the form again, showing the errors. So what I do is submit the form to its handler using Ajax.Request, and update the form DIV from within the onComplete function. If the form is bad, the handler will mark the bad fields and re-display it. But if it''s good, the handler sends back a little bit of HTML to say thanks, and a script block containing this line: $(''reflist'').insert({top:''<li>stuff from form</li>''}); I have this entirely working in Firefox 2, Firebug reports no errors at all. In Safari 3, if I inspect the page, I can see that the correct JavaScript is coming back, but it''s apparently not firing. I''ve tried all sorts of things, even very basic alerts, but they''re not firing. The code that should be firing is in a script tag, and the Element.update documentation clearly states that any such code will be executed when the element is updated. And in Firefox, this seems to be the case. I am using 1.6.0.2. Does this ring a bell for anyone? Thanks in advance, Walter --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Walter Lee Davis
2008-Feb-05 21:37 UTC
Re: Element.update not triggering scripts in Safari 3
On Feb 5, 2008, at 3:10 PM, Walter Lee Davis wrote:> In Safari 3, if I inspect the page, I can see that the correct > JavaScript is coming back, but it''s apparently not firing. I''ve tried > all sorts of things, even very basic alerts, but they''re not firing. > > The code that should be firing is in a script tag, and the > Element.update documentation clearly states that any such code will > be executed when the element is updated. And in Firefox, this seems > to be the case. >A bit more troubleshooting has unlocked part of the mystery. The code I am inserting is a full <li>, and I am adding it into an UL. So my fragment looks like this: <li><p>A comment, just made by the person using the form</p><p class="author">—Person''s Name</p></li> If I try to insert that using Safari, I get nothing -- no error -- just nothing. If I encode it in HTML entities, then it inserts, but of course displays as code -- not what I want. If I encode it in HTML entities, then insert it with $ (''reflist'').insert({top:mycode.unescapeHTML()}), then it ALMOST works -- everything is fine except for the class="author" part, which Safari''s Web Inspector shows as being coded as class=""author"" (and of course does not honor). Through it all, Firefox is a good soldier, and does what I want. It seems as though the whole problem is with escaping characters while passing the string to insert, but I''m completely baffled how to get this to work. Should I try JSON encoding the parameter? Or maybe build up the inserted LI from DOM objects? Thanks in advance, Walter --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Walter Lee Davis
2008-Feb-06 15:38 UTC
Re: Element.update not triggering scripts in Safari 3
Still more spelunking found another fix, related to the first. I had, in my code to be inserted, a Unicode em-dash. When I changed this to a decimal entity, everything worked again in Safari. Very odd. I suppose that this is a Safari bug, since I can''t duplicate it on Firefox. Walter On Feb 5, 2008, at 4:37 PM, Walter Lee Davis wrote:> > > On Feb 5, 2008, at 3:10 PM, Walter Lee Davis wrote: > >> In Safari 3, if I inspect the page, I can see that the correct >> JavaScript is coming back, but it''s apparently not firing. I''ve tried >> all sorts of things, even very basic alerts, but they''re not firing. >> >> The code that should be firing is in a script tag, and the >> Element.update documentation clearly states that any such code will >> be executed when the element is updated. And in Firefox, this seems >> to be the case. >> > > A bit more troubleshooting has unlocked part of the mystery. The code > I am inserting is a full <li>, and I am adding it into an UL. So my > fragment looks like this: > > <li><p>A comment, just made by the person using the form</p><p > class="author">—Person''s Name</p></li> > > If I try to insert that using Safari, I get nothing -- no error -- > just nothing. > > If I encode it in HTML entities, then it inserts, but of course > displays as code -- not what I want. > > If I encode it in HTML entities, then insert it with $ > (''reflist'').insert({top:mycode.unescapeHTML()}), then it ALMOST works > -- everything is fine except for the class="author" part, which > Safari''s Web Inspector shows as being coded as class=""author"" (and > of course does not honor). > > Through it all, Firefox is a good soldier, and does what I want. > > It seems as though the whole problem is with escaping characters > while passing the string to insert, but I''m completely baffled how to > get this to work. Should I try JSON encoding the parameter? Or maybe > build up the inserted LI from DOM objects? > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---