NEED HELP dieing here

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&quot; lang="en">   <head profile="http://gmpg.org/xfn/11&quot;&gt;     <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

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&quot; lang="en">   <head profile="http://gmpg.org/xfn/11&quot;&gt;     <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

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 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