Hi There, I am using a series of replace_html calls to update multiple parts of a web page, and this all works fine, although sometimes there is an odd js error that I mailed about previously. illegal character[ http://localhost:3000/javascripts/prototype.js?1186008779] \n//<![CDATA[\nnew Draggable(\"context_41\", {ghosting:true, revert:true})\n//]]>\n Thing is that error doesn''t stop me getting the desired output and neither do these odd requests for images that go on in the background. Although my application runs fine, the server is hit with a number of request for images that fail due to some munged escape characters: ActionController::RoutingError (no route found to match "/\\\"http:// static.flickr.com/1380/858130410_568ab071d0_m.jpg\\\"" with {:method=>:get}): However, all the images display fine in the browser itself. The code in my rails controller is like this: if request.xhr? @artifacts = Artifact.get_artifacts(@session_user, @context_elements) render :action => ''update_panes'', :type=>''rjs'' and return true end and update_panes.rjs is like this: page.replace_html ''context'' , :partial => ''layouts/context'', :locals => {:context_elements=>@context_elements, :context_present=>@context_present} page.replace_html ''recent'' , :partial => ''layouts/recent'', :locals => {:recent_elements=>@recent_elements, :context_present=>@context_present} page.replace_html ''artifacts'' , :partial => ''artifacts/list'', :locals => {:artifacts => @artifacts,:context_present=>@context_present} page.replace_html ''context_title'' , :partial => ''layouts/ context_title'', :locals => {:context_present=>@context_present} Here''s a successful ajax response from rails: Element.update("context", "<ul id=''context_list'' style=''border:1px solid #E8A400;min-height:20px;''>\n\n\n<li class=''context_item'' id=''context_24'' style=''padding:5px;cursor:-moz-grab;''>\n\n<img alt\"806128150_c62865fa22_m\" height=\"32\" src=\"http:// static.flickr.com/1069/806128150_c62865fa22_m.jpg\" width=\"32\" />\n \n <a href=\"#\" onclick=\"new Ajax.Updater(''context'', ''/contexts/ 1'', {asynchronous:true, evalScripts:true, method:''delete'', onComplete:function(request){eval(request.responseText)}}); return false;\">-</a></li>\n<script type=\"text/javascript\">\n//<! [CDATA[\nnew Draggable(\"context_24\", {ghosting:true, revert:true}) \n//]]>\n</script>\n\n</ul>"); Element.update("recent", "<ul id=''recent_list'' style=''border:1px solid #E8A400;min-height:20px;''>\n\n\n<li class=''list_item'' id=''recent_24'' style=''padding:5px;cursor:-moz-grab;''>\n\n<img alt\"806128150_c62865fa22_m\" height=\"32\" src=\"http:// static.flickr.com/1069/806128150_c62865fa22_m.jpg\" width=\"32\" />\n \n <a href=\"#\" onclick=\"new Ajax.Updater(''recent'', ''/recents/1'', {asynchronous:true, evalScripts:true, method:''delete'', onComplete:function(request){eval(request.responseText)}}); return false;\">-</a></li>\n<script type=\"text/javascript\">\n//<! [CDATA[\nnew Draggable(\"recent_24\", {ghosting:true, revert:true}) \n//]]>\n</script>\n\n</ul>"); Element.update("artifacts", "\n"); Element.update("context_title", "<a href=\"/permalink? context=24\">Context</a>\n"); and as I say I get errors like the following from, I assume, attempts by the browser to access these images. ActionController::RoutingError (no route found to match "/\\\"http:// static.flickr.com/1069/806128150_c62865fa22_m.jpg\\\"" with {:method=>:get}) This isn''t a critical problem, but it affects the scalability of the application as I''d hate the have the server bombarded with these nonsense requests every time an img src tag is loaded via ajax. I will be very grateful for any insights in into this issue. Many thanks in advance. CHEERS> SAM --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Christophe Porteneuve
2007-Aug-02 06:13 UTC
Re: img tags having strange effect during page.replace_html
Hey, Why not using a simple Ajax.Updater over the element''s container instead of going to all the trouble of your RJS which does nothing but a partial-based replace_html? That would be so much less roundabout... -- 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 -~----------~----~----~----~------~----~------~--~---
Hi Christophe, Thanks for getting back to me. I''m not sure how that would work. I need to update a number of elements in the web page and in Rails 1.2 using rjs and replace_html appeared to be the recommended way to do that. Are you suggesting I put Ajax.Updater statements in a template file? I would be most grateful if you could describe your proposed change in a little more detail, e.g. where would the Ajax.Updater go? In a different template file? The rjs and replace_html seems to be the most coherent way to pul in a number of other rhtml templates that are also used in other places. Many thanks in advance CHEERS> SAM On Aug 2, 3:13 pm, Christophe Porteneuve <t...-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org> wrote:> Hey, > > Why not using a simple Ajax.Updater over the element''s container instead > of going to all the trouble of your RJS which does nothing but a > partial-based replace_html? That would be so much less roundabout... > > -- > 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 -~----------~----~----~----~------~----~------~--~---