When I try and use rjs rails just outputs the text of the javascript I am trying to call with page.call javascript is enabled, I have tried setting config.action_view.debug_rjs to false and commenting it out in the development environment. I have created a new app with no other javascript libraries and just tried to use rjs to call a simple javascript function. I have the include defaults tag in the layout. In Firebug it says <pre>try { <SCRIPT type="text/javascript"> myfunction("pics\ \test1.jpeg"); </script> } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert('' <SCRIPT type=\"text/javascript\"> \nmyfunction(\"pics\\\\test1.jpeg\");\n </script>''); throw e }</pre> what is this pre thing, and why won''t it just call the javascript. This is killing me either there is some configuration everyone knows about that isn''t posted anywhere or I haven''t come across a tutorial that shows it or this is a bug in rails. Please help trying def index @images = Image.find(:all) render :update do |page| page << '' <SCRIPT type="text/javascript">'' page.call ''myfunction'', ''pics\test1.jpeg'' page << '' </script>'' end #render :index end have tried redirecting to an action with the render stuff, the page still only has that <pre> thing in the body. the layout looks like: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1- strict.dtd"> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Your title</title> <script type="text/javascript" src="mootools.js"></script> <script type="text/javascript" src="croppr.js"></script> <link rel="stylesheet" type="text/css" href="main.css"/> <script type="text/javascript"> function myfunction(src) --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Tue, Mar 4, 2008 at 11:21 AM, sweiss <weisssteven-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> > When I try and use rjs rails just outputs the text of the javascript I > am trying to call with page.call > > javascript is enabled, I have tried setting > config.action_view.debug_rjs to false and commenting it out in the > development environment. I have created a new app with no other > javascript libraries and just tried to use rjs to call a simple > javascript function. I have the include defaults tag in the layout. > > In Firebug it says > > <pre>try { <SCRIPT type="text/javascript"> myfunction("pics\ > \test1.jpeg"); </script> } catch (e) { alert(''RJS error:\n\n'' + > e.toString()); alert('' <SCRIPT type=\"text/javascript\"> > \nmyfunction(\"pics\\\\test1.jpeg\");\n </script>''); throw e }</pre> > > what is this pre thing, and why won''t it just call the javascript. > This is killing me either there is some configuration everyone knows > about that isn''t posted anywhere or I haven''t come across a tutorial > that shows it or this is a bug in rails. Please help > > trying > def index > @images = Image.find(:all) > render :update do |page| > page << '' <SCRIPT type="text/javascript">'' > page.call ''myfunction'', ''pics\test1.jpeg'' > page << '' </script>'' > end > #render :index > end > > have tried redirecting to an action with the render stuff, the page > still only has that <pre> thing in the body. > > the layout looks like: > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1- > strict.dtd"> > <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"> > <head profile="http://gmpg.org/xfn/11"> > <meta http-equiv="Content-Type" content="text/html; > charset=UTF-8" /> > <title>Your title</title> > <script type="text/javascript" src="mootools.js"></script> > <script type="text/javascript" src="croppr.js"></script> > <link rel="stylesheet" type="text/css" href="main.css"/> > <script type="text/javascript"> > function myfunction(src) > >Hi sweiss Make sure in your layout you have the script tags to load prototype. <%= javascript_include_tag :defaults %> HTH Daniel --~--~---------~--~----~------------~-------~--~----~ 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 get the same thing, I had just coppied an old layout, the layout looks liek this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1- strict.dtd"> <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Your title</title> <script type="text/javascript" src="mootools.js"></script> <script type="text/javascript" src="croppr.js"></script> <%= javascript_include_tag :defaults %> <link rel="stylesheet" type="text/css" href="main.css"/> <script type="text/javascript"> function myfunction(src) {} </script> </head> <body> <div id="controls"> <div id="image"> <img id="master1" src="/pics/master1.jpeg" width="107" height="98" /> </div> <form> <input type="button" onclick="myfunction(''/pics/test1.jpeg'')" value="Call function"> </form> </div> <%= yield :layout %> </body> </html> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Tue, Mar 4, 2008 at 11:33 AM, sweiss <weisssteven-PkbjNfxxIARBDgjK7y7TUQ@public.gmane.org> wrote:> > I get the same thing, I had just coppied an old layout, the layout > looks liek this: > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1- > strict.dtd"> > <html xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"> > <head profile="http://gmpg.org/xfn/11"> > <meta http-equiv="Content-Type" content="text/html; > charset=UTF-8" /> > <title>Your title</title> > <script type="text/javascript" src="mootools.js"></script> > <script type="text/javascript" src="croppr.js"></script> > <%= javascript_include_tag :defaults %> > <link rel="stylesheet" type="text/css" href="main.css"/> > <script type="text/javascript"> > function myfunction(src) > {} > > </script> > </head> > <body> > <div id="controls"> > <div id="image"> > <img id="master1" src="/pics/master1.jpeg" width="107" > height="98" /> > </div> > <form> > <input type="button" > onclick="myfunction(''/pics/test1.jpeg'')" > value="Call function"> > </form> > </div> > <%= yield :layout %> > </body> > </html> > >Don''t know then sorry... Is it safe to use prototype and mootools in the same app? Cheers --~--~---------~--~----~------------~-------~--~----~ 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 heard that it wasn''t, and the thing to make the compatible was to replae the $ in moo tools with something else so that symbol wouldn''t conflict, I tried that. I also created an empty app that did not have moo tools in it, just to try and call a javascript function with rjs, and it keeps on printiong out the text of what it should be making call as a function. I know prototype is being used since it parses in the try{.. catch (rjs error stuff, just don''t know why it doesn''t actually execute the code --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 4 Mar 2008, at 00:21, sweiss wrote:> > When I try and use rjs rails just outputs the text of the javascript I > am t > trying > def index > @images = Image.find(:all) > render :update do |page| > page << '' <SCRIPT type="text/javascript">'' > page.call ''myfunction'', ''pics\test1.jpeg'' > page << '' </script>'' > end > #render :index > endYou don''t need that <SCRIPT type="text/javascript">. the thing that parses the response knows that it''s javascript to evaluate, so you''re asking the javascript interpreter to evaluate <SCRIPT type="text/javascript"> which it can''t since that''s not legal javascript (you can see this from what firebug shows you). Remove the two page << (and make sure that when you use link_to_remote you aren''t using the :update option) and you should be ok. Fred --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---