Just wondering if anyone could help me wrap my mind around some of this ajax stuff and how to get some of those rjs partials to work (if even necessary). I was thinking of having a page that would be something like: (index.rhtml) <html> <head> <%= javascript_include_tag :defaults %> </head> <body> <% for each user in @users %> <div class="person"> <div id="uID<%= user.id %>My name is <%= user.name %></div> <div> <%= form_remote_tag :url => { :action => :highlightName, :id=>user.id } %> <%= submit_tag "Hightlight my Name" %> <%= end_form_tag %> </div> </div><p> <% end %> </body> </html> From the examples I''ve seen the controller would have something like class TestController < ApplicationController def index @users = User.find(:all) end def highlightName @uID = params[:id] #... some magic goes here redirect_to_index unless request.xhr? end def redirect_to_index() redirect_to :action => :index end end I know I''m missing something here, but the thing''s ive tried haven''t provided me much feed back on whats happening behind the scenes. -- 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 -~----------~----~----~----~------~----~------~--~---
Consider spending $9 @ peepcode to download the 45-min. RJS screencast, a rails pro talks you through it all. http://www.peepcode.com/articles/2006/08/13/rjs-templates -Ryan> Just wondering if anyone could help me wrap my mind around some of this > ajax stuff and how to get some of those rjs partials to work (if even > necessary).--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Hi Mic, If you want you highlightName Action to render a partial, you need to omit your redirect statement. Each action can only have one redirect or render statement. If you omit the redirect statement, the controller will look for an rhtml, rjs or rxml document in the folder associated with your controller. In your case it would be app/views/test/highlight_name.rhtml Put whatever rjs logic you want in there, and rails will take care of the rest. Hope that helps -josh On 10/5/06, Mic <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > Just wondering if anyone could help me wrap my mind around some of this > ajax stuff and how to get some of those rjs partials to work (if even > necessary). > > I was thinking of having a page that would be something like: > (index.rhtml) > <html> > <head> > <%= javascript_include_tag :defaults %> > </head> > <body> > <% for each user in @users %> > <div class="person"> > <div id="uID<%= user.id %>My name is <%= user.name %></div> > <div> > <%= form_remote_tag :url => { :action => :highlightName, > :id=>user.id } %> > <%= submit_tag "Hightlight my Name" %> > <%= end_form_tag %> > </div> > </div><p> > <% end %> > </body> > </html> > > From the examples I''ve seen the controller would have something like > > class TestController < ApplicationController > def index > @users = User.find(:all) > end > > def highlightName > @uID = params[:id] > #... some magic goes here > redirect_to_index unless request.xhr? > end > > def redirect_to_index() > redirect_to :action => :index > end > end > > I know I''m missing something here, but the thing''s ive tried haven''t > provided me much feed back on whats happening behind the scenes. > > -- > 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 -~----------~----~----~----~------~----~------~--~---