Hi guys, I''m having problems with RJS, and can''t figure it out... I''m using RJS to do a very simple effect on a div: page.visual_effect :blind_up, ''comment-''+@id The request works, but the javascript it sends to the browser doesn''t work: try { new Effect.BlindUp("comment-9",{}); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''new Effect.BlindUp(\"comment-9\",{ });''); throw e } The new lines inside the code end up causing an "unterminated string literal" error on the browser.. If i remove them manually, it works correctly. Do you guys have any idea?? Thanks!! -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
What about page[''comment''+@id].visual_effect :blind_up On Aug 10, 5:19 am, Eduardo Scoz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hi guys, > > I''m having problems with RJS, and can''t figure it out... I''m using RJS > to do a very simple effect on a div: > > page.visual_effect :blind_up, ''comment-''+@id > > The request works, but the javascript it sends to the browser doesn''t > work: > > try { > > new Effect.BlindUp("comment-9",{}); > > } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''new > > Effect.BlindUp(\"comment-9\",{ > > });''); throw e } > > The new lines inside the code end up causing an "unterminated string > literal" error on the browser.. If i remove them manually, it works > correctly. > > Do you guys have any idea?? > > Thanks!! > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
nigel.bris wrote:> What about > > page[''comment''+@id].visual_effect :blind_up > > On Aug 10, 5:19 am, Eduardo Scoz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>Hi Nigel, Thanks for the reply. Unfortunately, it didn''t work.. It generated the same javascript, with the extra line breaks.. -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I realise now, my code should not of worked (unless @id is already a string) so it should be @id.to_s... But this this not the issue because your code shows the "comment-9" Do you have javascript_include_tag :defaults ? Here is my test (which works), otherwise use firefox and firebug to debug Hope this helps index.rhtml <html> <head> <%=javascript_include_tag :defaults %> </head> <body> <div id="comment-1" style="background-color: red"> a<br> </div> <%=link_to_remote "press me", :url=>{:action=>:hide_me} %> </body> </html> hide_me.rjs @id=1 page[''comment-''+@id.to_s].visual_effect :blind_up On Aug 11, 12:28 am, Eduardo Scoz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> nigel.bris wrote: > > What about > > > page[''comment''+@id].visual_effect :blind_up > > > On Aug 10, 5:19 am, Eduardo Scoz <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> > > Hi Nigel, > > Thanks for the reply. Unfortunately, it didn''t work.. It generated the > same javascript, with the extra line breaks.. > > -- > Posted viahttp://www.ruby-forum.com/.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Thanks, Nigel, I''ll give it a try soon, and let you know. I''m using a compacted scriptaculous library instead of the default ones, but it work fine.. the problem was really with the spaces.. fixing them manually on firebug was making it work. Thanks a lot! Eduardo -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Eduardo Scoz wrote:> Thanks, Nigel, > > I''ll give it a try soon, and let you know. > > I''m using a compacted scriptaculous library instead of the default ones, > but it work fine.. the problem was really with the spaces.. fixing them > manually on firebug was making it work. > > Thanks a lot! > > EduardoHi there, I have the exact same problem. I''m using a RJS for creating a new li element. This happens with a partial. create.rjs page.insert_html :bottom, ''playlist'', :partial => ''songs/song_listing'', :locals => {:song => @song} song_listing partial <li id="song_<%=song.id.to_s%>"><%=h song.artist%> - <%=h song.name%> <%if logged_in?%>(<%=link_to_remote "Remove".t, :url => { :controller => "playlists", :action => "destroy_song", :id => song.id }, :confirm => ''Are you sure you want to delete this song?''.t %>)<% end %></li> This partial doesn''t have any unnecessary spaces or line breaks! But what I get in Firebug is the following (including the line breaks!): new Insertion.Bottom("playlist", "<li id=\"song_100\">TestArtist - TestName (<a href=\"#\" onclick=\"if (confirm(''Are you sure you want to delete this song?'')) { new Ajax.Request(''/en/playlists/destroy_song /100'', {asynchronous:true, evalScripts:true}); }; return false;\">Remove</a>)</li>"); As soon as I remove the line breaks, everything is executed just fine. I''m sitting at this problem for some time now. The whole thing worked for some time. I added a similar functionality to a different section on my site and both stopped working. I double-checked everything and can''t see any problems. Did you solved the problem yet? Any suggestions or tips for my case? Bye Axel -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Axel! I haven''t still been able to figure out that problem.. I ended up working on some other things, hoping somebody would know the solution.. :) Well, at least I''m not the only one with the problem now. I''ll try to trace the rails code to find out where this problem is being created. I''ll post an update here if I find out anything. Please let me know if you find anything as well! Regards Eduard -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Did you try using <%= -%> instead of <%= %> ? (the dash-percent- greaterthan is supposed to not spit out an additional #\linefeed). On Aug 15, 2007, at 4:03 PM, Axel Benjamins wrote:> > Eduardo Scoz wrote: >> Thanks, Nigel, >> >> I''ll give it a try soon, and let you know. >> >> I''m using a compacted scriptaculous library instead of the default >> ones, >> but it work fine.. the problem was really with the spaces.. fixing >> them >> manually on firebug was making it work. >> >> Thanks a lot! >> >> Eduardo > > Hi there, > > I have the exact same problem. I''m using a RJS for creating a new li > element. This happens with a partial. > > create.rjs > page.insert_html :bottom, ''playlist'', :partial => > ''songs/song_listing'', :locals => {:song => @song} > > song_listing partial > <li id="song_<%=song.id.to_s%>"><%=h song.artist%> - <%=h > song.name%> > <%if logged_in?%>(<%=link_to_remote "Remove".t, :url => > { :controller => > "playlists", :action => "destroy_song", :id => song.id }, :confirm => > ''Are you sure you want to delete this song?''.t %>)<% end %></li> > > This partial doesn''t have any unnecessary spaces or line breaks! But > what I get in Firebug is the following (including the line breaks!): > > new Insertion.Bottom("playlist", "<li id=\"song_100\">TestArtist - > TestName (<a href=\"#\" onclick=\"if > > (confirm(''Are you sure you want to delete this song?'')) { new > Ajax.Request(''/en/playlists/destroy_song > > /100'', {asynchronous:true, evalScripts:true}); }; return > false;\">Remove</a>)</li>"); > > > As soon as I remove the line breaks, everything is executed just fine. > I''m sitting at this problem for some time now. The whole thing worked > for some time. I added a similar functionality to a different > section on > my site and both stopped working. I double-checked everything and > can''t > see any problems. > > Did you solved the problem yet? Any suggestions or tips for my case? > > Bye > Axel > -- > Posted via http://www.ruby-forum.com/. > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Paul Hoehne wrote:> Did you try using <%= -%> instead of <%= %> ? (the dash-percent- > greaterthan is supposed to not spit out an additional #\linefeed).I tried your idea (sounded reasonable), but it still didn''t work. And I''m slowly running out of other ideas. I think I''m gonna lay this thing aside for some days and try it again in a week. Perhaps I got some fresh ideas by then. Nevertheless, thanks for your help! I let you know, as soon as I find anything out. Bye Axel -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Eduardo Scoz wrote:> Hi guys, > > I''m having problems with RJS, and can''t figure it out... I''m using RJS > to do a very simple effect on a div: > > page.visual_effect :blind_up, ''comment-''+@id > > The request works, but the javascript it sends to the browser doesn''t > work: > > try { > > new Effect.BlindUp("comment-9",{}); > > } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''new > Effect.BlindUp(\"comment-9\",{ > > });''); throw e } > > > The new lines inside the code end up causing an "unterminated string > literal" error on the browser.. If i remove them manually, it works > correctly.There used to be a bug in the RJS JavaScript debugging code, but it was fixed some time ago. Are you using actionpack-1.13.3? Alternatively, turn off the debug code by adding config.action_view.debug_rjs = false inside the Rails::Initializer.run block in environment.rb. -- We develop, watch us RoR, in numbers too big to ignore. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Mark! thanks for the reply.. Unfortunately, it''s still not working. I''m using Actionpack-1.13.3. I tried the "debug_rjs = false", but I still get the exact same JS as the output. In regard to the previous post, about using <%= -%>, I''m not even using those tags, I just have the page[''a''].visual_effect command directly on the RJS file. Thanks a lot for the help so far, everybody.. Mark Reginald James wrote:> Eduardo Scoz wrote: >> try { >> literal" error on the browser.. If i remove them manually, it works >> correctly. > > There used to be a bug in the RJS JavaScript debugging code, but it > was fixed some time ago. Are you using actionpack-1.13.3? > > Alternatively, turn off the debug code by adding > > config.action_view.debug_rjs = false > > inside the Rails::Initializer.run block in environment.rb. > > -- > We develop, watch us RoR, in numbers too big to ignore.-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
hi everybody, just for the record, I ended up finding out what the problem was. I had added a function to the application.rb to include headers on every request to set the proper response content-type and content-language. The problem is that those two things were being added to _every_ request, even JS ones. That was causing the problem. After commenting out those two lines, everything is working again. Thanks for everybody! Eduardo -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi Eduardo, thanks very much. I had the same problem. After some googling I found the following: http://nubyonrails.com/articles/rjs-and-content-type-header (see the section labeled "Content-Type Header") Just use a before_filter instead of an after_filter. The content-type will only be set, whenever a template is rendered, which needs a content-type. RJS templates will be ignored and rendered correctly. Again, big thanks for posting the solution. Would have searched another month for this... Bye Axel Eduardo Scoz wrote:> hi everybody, > > just for the record, I ended up finding out what the problem was. > > I had added a function to the application.rb to include headers on every > request to set the proper response content-type and content-language. > > The problem is that those two things were being added to _every_ > request, even JS ones. That was causing the problem. > > After commenting out those two lines, everything is working again. > > Thanks for everybody! > > Eduardo-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Great to know it worked for you as well, Axel! Thanks for the link. Axel Benjamins wrote:> Hi Eduardo, > > thanks very much. I had the same problem. After some googling I found > the following: > http://nubyonrails.com/articles/rjs-and-content-type-header (see the > section labeled "Content-Type Header") > > Just use a before_filter instead of an after_filter. The content-type > will only be set, whenever a template is rendered, which needs a > content-type. RJS templates will be ignored and rendered correctly. > > Again, big thanks for posting the solution. Would have searched another > month for this... > > Bye > Axel-- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---