Dick Davies
2006-Jan-10 15:27 UTC
[Rails] first ajax demo in Rails book - does it work for anyone?
Just tried the first AJAX example in the rails book (p.391-392, the ''word guessing'' thing), and the AJAX partial used seems to render as a full page. I''m not sure whether it''s a) a partial bug b) some interaction between ajax and partials c) a change since the book came out or d) pilot error I''ve checked the errata pages and it''s flagged up as b0rked there too (on windows; I''m on ubuntu breezy with rails v1.0). gmane drew a blank on the list archives, can anyone confirm/deny whether this worked for them? -- Rasputin :: Jack of All Trades - Master of Nuns http://number9.hellooperator.net/
Jules Jacobs
2006-Jan-10 15:41 UTC
[Rails] Re: first ajax demo in Rails book - does it work for anyone?
Could you post the code you''re using? render :partial => ''yourpartial'' shouldn''t include a layout... -- Posted via http://www.ruby-forum.com/.
Dick Davies
2006-Jan-10 20:44 UTC
[Rails] Re: first ajax demo in Rails book - does it work for anyone?
Thanks Jules, but it''s really just the code from the book (unless I fat-fingered something). It does''nt use a layout, just a partial. Essentially the URL updates to point to the action that form_remote_tag is calling via AJAX, which I don''t think it should. I can post code if this is ringing no bells at all... On 10/01/06, Jules Jacobs <julesjacobs@gmail.com> wrote:> Could you post the code you''re using? > > render :partial => ''yourpartial'' > > shouldn''t include a layout... > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Rasputin :: Jack of All Trades - Master of Nuns http://number9.hellooperator.net/
Jules Jacobs
2006-Jan-10 21:05 UTC
[Rails] Re: Re: first ajax demo in Rails book - does it work for any
Please post your code if this: render :partial => ''form'', :layout => false doesn''t help. -- Posted via http://www.ruby-forum.com/.
Dave Thomas
2006-Jan-11 07:18 UTC
[Rails] first ajax demo in Rails book - does it work for anyone?
On Jan 10, 2006, at 9:27, Dick Davies wrote:> Just tried the first AJAX example in the rails book (p.391-392, the > ''word guessing'' thing), and the AJAX partial used seems to render as a > full page. > > I''m not sure whether it''s > > a) a partial bug > b) some interaction between ajax and partials > c) a change since the book came out > or > d) pilot errorI''ll be looking at these incompatibilities over the coming months: I''m guessing that adding :layout => false will fix it. Dave
Dan Shafer
2006-Jan-11 07:39 UTC
[Rails] Re: first ajax demo in Rails book - does it work for anyone?
that code (p. 392 in the printed version if I''m following you) is noted as erroneous at the book''s Web site: http://books.pragprog.com/titles/rails/errata Not sure if the comment following that one will help you because I didn''t see your original post on this thread. On Jan 10, 2006, at 12:44 PM, Dick Davies wrote:> Thanks Jules, but it''s really just the code from the book > (unless I fat-fingered something). It does''nt use a layout, > just a partial. > > Essentially the URL updates to point to the action that > form_remote_tag is calling via AJAX, which I don''t think it > should. > > I can post code if this is ringing no bells at all... > > On 10/01/06, Jules Jacobs <julesjacobs@gmail.com> wrote: >> Could you post the code you''re using? >> >> render :partial => ''yourpartial'' >> >> shouldn''t include a layout... >> >> -- >> Posted via http://www.ruby-forum.com/. >> _______________________________________________ >> Rails mailing list >> Rails@lists.rubyonrails.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > > -- > Rasputin :: Jack of All Trades - Master of Nuns > http://number9.hellooperator.net/ > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-. -.-.-.-.-.-.-.-.-.-.-.-.-.-.- Dan Shafer Technology Visionary - Technology Assessment - Documentation "Looking at technology from every angle" http://www.eclecticity.com
Steve Litt
2006-Jan-11 13:08 UTC
[Rails] first ajax demo in Rails book - does it work for anyone?
On Wednesday 11 January 2006 02:18 am, Dave Thomas wrote:> On Jan 10, 2006, at 9:27, Dick Davies wrote: > > Just tried the first AJAX example in the rails book (p.391-392, the > > ''word guessing'' thing), and the AJAX partial used seems to render as a > > full page. > > > > I''m not sure whether it''s > > > > a) a partial bug > > b) some interaction between ajax and partials > > c) a change since the book came out > > or > > d) pilot error > > I''ll be looking at these incompatibilities over the coming months: > I''m guessing that adding :layout => false will fix it.On my .pdf version of the book, your book has: render(:layout => false) SteveT Steve Litt Author: * Universal Troubleshooting Process courseware * Troubleshooting Techniques of the Successful Technologist * Rapid Learning: Secret Weapon of the Successful Technologist Webmaster * Troubleshooters.Com * http://www.troubleshooters.com
Dick Davies
2006-Jan-11 14:29 UTC
[Rails] first ajax demo in Rails book - does it work for anyone?
Nope, still b0rked - here''s all the source (and there''s a tarred up app directory at http://files.hellooperator.net/aj.tgz ) Thanks for everyone''s suggestions so far, and apologies in advance for when it turns out to be a typo.... ------------------------------------------------------------ sisred@planb:~/Desktop/aj$ cat app/views/ajax_test/_form.rhtml <% if @guess %> <p>don''t think ''<%= h(@guess) %>'' is right....</p> <% end %> <%= form_remote_tag(:update => ''update_div'', :url => { :action => :guess } ) %> <label for=''guess''>thick as 2 short....?</label> <%= text_field_tag :guess %> <%= submit_tag ''do the ajax thing'' %> <%= end_form_tag %> sisred@planb:~/Desktop/aj$ cat app/views/ajax_test/guess.rhtml <h1>AjaxTest#guess</h1> <p>Find me in app/views/ajax_test/guess.rhtml</p> sisred@planb:~/Desktop/aj$ cat app/views/ajax_test/_form.rhtml <% if @guess # if it was right, we wouldn''t be rendering this partial %> <p>don''t think ''<%= h(@guess) %>'' is right....</p> <% end %> <%= form_remote_tag(:update => ''update_div'', :url => { :action => :guess } ) %> <label for=''guess''>thick as 2 short....?</label> <%= text_field_tag :guess %> <%= submit_tag ''do the ajax thing'' %> <%= end_form_tag %> sisred@planb:~/Desktop/aj$ cat app/views/ajax_test/index.rhtml <h1>have a guess</h1> <div id="update_div" style="background.color:#ddd"> <%= render(:partial => ''form'', :layout => false ) %> </div> </p> sisred@planb:~/Desktop/aj$ cat app/controllers/ajax_test_controller.rb class AjaxTestController < ApplicationController def index end def guess @guess = params[:guess] || '''' if @guess.strip.match /^planks$/i render(:text => ''right on commander'') else render(:partial => ''form'', :layout => false) end end end ------------------------------------------------------------ On 11/01/06, Dave Thomas <Dave@pragprog.com> wrote:> > On Jan 10, 2006, at 9:27, Dick Davies wrote: > > > Just tried the first AJAX example in the rails book (p.391-392, the > > ''word guessing'' thing), and the AJAX partial used seems to render as a > > full page. > > > > I''m not sure whether it''s > > > > a) a partial bug > > b) some interaction between ajax and partials > > c) a change since the book came out > > or > > d) pilot error > > I''ll be looking at these incompatibilities over the coming months: > I''m guessing that adding :layout => false will fix it. > > > Dave > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- Rasputin :: Jack of All Trades - Master of Nuns http://number9.hellooperator.net/
Dick Davies
2006-Jan-11 16:37 UTC
[Rails] first ajax demo in Rails book - does it work for anyone?
On 11/01/06, Steve Litt <slitt@troubleshooters.com> wrote:> On my .pdf version of the book, your book has: > > render(:layout => false)To clarify, I''m talking about the deadtree version, and adding the :layout => false key to the options hash does''nt appear to make any difference. -- Rasputin :: Jack of All Trades - Master of Nuns http://number9.hellooperator.net/