I am running Rails 1.10 and wanted to check out the RJS templates. Rails doesn''t seem to find them. I did issue the rake comment update_javascripts and that did not correct the problem. RJS is part of 1.1 right? Any ideas? Thanks. -- Posted via http://www.ruby-forum.com/.
Arch Stanton wrote:> I am running Rails 1.10 and wanted to check out the RJS templates. > Rails doesn''t seem to find them. > > I did issue the rake comment update_javascripts and that did not correct > the problem. RJS is part of 1.1 right? > > Any ideas? > > Thanks.Apparently I was still on 1.0. So I am getting the RJS templates recgonized now, however I am now getting weird output: page display: # try { new Insertion.Bottom("test_1", "Fox # "); new Effect.Highlight("list",{duration:3}); } catch (e) { alert(''RJS error:\n\n'' + e.toString()); alert(''new Insertion.Bottom(\"test_1\", \"Fox \");\nnew Effect.Highlight(\"list\",{duration:3});''); throw e } controller: def take_test2 end rjs template: page.insert_html :bottom, ''test_1'', content_tag("li", "Fox") page.visual_effect :highlight, ''list'', :duration => 3 -- Posted via http://www.ruby-forum.com/.
I did some more testing. Even turned debugging off for RJS templates but still I am getting the source displayed on my page. So for this RJS template: ## rjs template page.insert_html :bottom, "test_1", :partial => "take_test" page.visual_effect :highlight, "test_1", :duration => 10 ## rhtml partial <div class="take_test"> <h3>Post</h3> <p>post text</p> </div> I am getting this displayed in the browser: new Insertion.Bottom("test_1", " \n Post \n post text \n "); new Effect.Highlight("test_1",{duration:10}); -- Posted via http://www.ruby-forum.com/.
Arch Stanton wrote:> I did some more testing. Even turned debugging off for RJS templates > but still I am getting the source displayed on my page. > > So for this RJS template: > ## rjs template > page.insert_html :bottom, "test_1", :partial => "take_test" > page.visual_effect :highlight, "test_1", :duration => 10 > > ## rhtml partial > <div class="take_test"> > <h3>Post</h3> > <p>post text</p> > </div> > > > I am getting this displayed in the browser: > > new Insertion.Bottom("test_1", " > \n > Post > \n > > post text > \n > "); new Effect.Highlight("test_1",{duration:10});When you link to the action which uses RJS, use link_to_remote instead of link_to. Jeff Coleman -- Posted via http://www.ruby-forum.com/.
Jeff Coleman wrote:> > When you link to the action which uses RJS, use link_to_remote instead > of link_to. > > Jeff ColemanYep I am using this call: <div id="test_1"> <p><%= link_to_remote("Take Kwiz RJS",:update =>"test_1",:url =>{ :action => "take_test2", :id => test.id}) %> </p> </div> -- Posted via http://www.ruby-forum.com/.
Arch > <div id="test_1"> <p><%= link_to_remote("Take Kwiz RJS",:update =>"test_1",:url =>{ > :action => "take_test2", :id => test.id}) %> </p> > </div> To summarize, your RJS ends up as plain test in your web page instead of being inserted and executed. Don''t you''re have a filter somewhere that sets the content type to text? Alain
On Apr 16, 2006, at 11:00 PM, Alain Ravet wrote:> Arch > > <div id="test_1"> <p><%= link_to_remote("Take Kwiz > RJS",:update =>"test_1",:url =>{ > > :action => "take_test2", :id => test.id}) %> </p> > > </div> > > To summarize, your RJS ends up as plain test in your web page > instead of being inserted and executed. > Don''t you''re have a filter somewhere that sets the content type to > text? > > Alain > > _______________________________________________Did you make sure to put the <%= javascript_include_tag :defaults % > in the head of the page getting served? -Ezra
Alain Ravet wrote:> Arch > > <div id="test_1"> <p><%= link_to_remote("Take Kwiz RJS",:update > =>"test_1",:url =>{ > > :action => "take_test2", :id => test.id}) %> </p> > > </div> > > To summarize, your RJS ends up as plain test in your web page instead of > being inserted and executed. > Don''t you''re have a filter somewhere that sets the content type to text? > > AlainCorrect. The content type is being set to text in my header: <head> <meta http-equiv="Content-Type" content="text/javascript" charset=UTF-8" /> <link href="/stylesheets/main.css" media="all" rel="Stylesheet" type="text/css" /> <script src="/javascripts/prototype.js" type="text/javascript"></script> <script src="/javascripts/effects.js" type="text/javascript"></script> <script src="/javascripts/dragdrop.js" type="text/javascript"></script> <script src="/javascripts/controls.js" type="text/javascript"></script> <script src="/javascripts/application.js" type="text/javascript"></script> </head> I''ve also tried <meta http-equiv="Content-Type" content="text/html" charset=UTF-8" /> And that did not help either. -- Posted via http://www.ruby-forum.com/.
Arch Stanton wrote:> Jeff Coleman wrote: > >> >> When you link to the action which uses RJS, use link_to_remote instead >> of link_to. >> >> Jeff Coleman > > Yep I am using this call: > > > <div id="test_1"> > <p><%= link_to_remote("Take Kwiz RJS",:update =>"test_1",:url =>{ > :action => "take_test2", :id => test.id}) %> </p> > </div>Try removing the :update parameter from your link_to_remote call. I believe what''s happening is that link_to_remote is sending the result of the call into the DIV "test_1", like it would if you''d called a partial. But since you''re dealing with RJS, your RJS calls will specify which DIV to update. Jeff Coleman -- Posted via http://www.ruby-forum.com/.
Ezra Zygmuntowicz wrote:> On Apr 16, 2006, at 11:00 PM, Alain Ravet wrote: > >> >> Alain >> >> _______________________________________________ > > > Did you make sure to put the <%= javascript_include_tag :defaults % > > in the head of the page getting served? > > -EzraYes, here is my layout: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html> <head> <title>Rails Application</title> <meta http-equiv="Content-Type" content="text/javascript" charset=UTF-8" /> <%= stylesheet_link_tag "main", :media => "all" %> <%= javascript_include_tag :defaults %> </head> -- Posted via http://www.ruby-forum.com/.
Jeff Coleman wrote:> > Try removing the :update parameter from your link_to_remote call. > > I believe what''s happening is that link_to_remote is sending the result > of the call into the DIV "test_1", like it would if you''d called a > partial. But since you''re dealing with RJS, your RJS calls will specify > which DIV to update. > > Jeff ColemanThat was it! Damn this one was really throwing me. Basically I had my whole app working with partials but wanted to try the RJS templates in 1.1.0, so the :udpate parameters were everywhere and thus none of my templates were working. What I don''t understand though is the RJS template was still being hit . . . oh wait I see . . . it was treating the the code block as the input and not actually running the code. Right? -- Posted via http://www.ruby-forum.com/.
Arch Stanton wrote:> Jeff Coleman wrote: > >> >> Try removing the :update parameter from your link_to_remote call. >> >> I believe what''s happening is that link_to_remote is sending the result >> of the call into the DIV "test_1", like it would if you''d called a >> partial. But since you''re dealing with RJS, your RJS calls will specify >> which DIV to update. >> >> Jeff Coleman > > That was it! Damn this one was really throwing me. > > Basically I had my whole app working with partials but wanted to try the > RJS templates in 1.1.0, so the :udpate parameters were everywhere and > thus none of my templates were working. > > What I don''t understand though is the RJS template was still being hit . > . . oh wait I see . . . it was treating the the code block as the input > and not actually running the code. Right?I believe that''s it--it was taking the JavaScript generated by the RJS template as the content and updating the specified DIV with it--rather than executing the JavaScript as code. I got confused by this at the start myself. :) Jeff -- Posted via http://www.ruby-forum.com/.