I have been using link_to_remote forever now. I have also been using jquery through jrails. I am readying my code for Rails 3.0, and am wondering what is the best way to accomplish. For example, I have something like this all over in Rails 2.0 <%= link_to_remote "XXX", { :url => "/activities/hide_dock", :update => "dock-container", :complete => "fixDock()" }, { :class => "activities" } %> def hide_dock render :partial => "/layouts/dock" end Now, in Rails 3.0 I am planning this <%= raw link_to "XXX", "/activities/hide_dock", {:remote => true, :class => "activities" } %> def hide_dock respond_to do |format| format.html format.js do ????? What do I put here ????? end end end My main question is since I am using jQuery, is there any point in using RJS? Should I just have render :layout => false and in hide_dock.js.erb just use jQuery code with <%= render :partial =>%> where appropriate. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Jun 17, 2010 at 9:51 PM, Sharkie Landshark <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote:> I have been using link_to_remote forever now. I have also been using > jquery through jrails. > > I am readying my code for Rails 3.0, and am wondering what is the best > way to accomplish. > > For example, I have something like this all over in Rails 2.0 > > <%= link_to_remote "XXX", > { :url => "/activities/hide_dock", :update => > "dock-container", :complete => "fixDock()" }, { :class => "activities" } > %> > >Sharkie, I would recommend reading the following first before you start upgrading from Rails 2.x to Rails 3.x: http://blog.peepcode.com/tutorials/2010/live-coding-rails-3-upgrade Next, link_to_remote has been deprecated in Rails 3 and you would need to do the following: <%= link_to "XXX", { :remote => true }, { ... } %>> def hide_dock > render :partial => "/layouts/dock" > end > > Now, in Rails 3.0 I am planning this > > <%= raw link_to "XXX", "/activities/hide_dock", > {:remote => true, :class => "activities" } > %> > >Next, the above shouldn''t use raw because link_to method returns an html_safe string in Rails 3.> def hide_dock > respond_to do |format| > format.html > format.js do > ????? What do I put here ????? >If you''re using RJS, then you''ll simple add the expression to be executed. For example, I tend to be partial to JSON and I would do the following: format.js # render the action.js.rjs by default or you can redefine it as follows to return json format.js { render :json => @some_object }> end > end > end > >It''s not clear as to what you''re trying to do. The hide_dock is a controller action so do you want to allow the following: http://some_domain.com/controller_name/hide_dock> My main question is since I am using jQuery, is there any point in using > RJS? > >If you intend on using jQuery, then there''s no need to use RJS. Just make sure that you get the JS file here: http://github.com/rails/jquery-ujs> Should I just have > > render :layout => false > >If you''re updating just a part of the page, then you''ll need to use the above.> and in hide_dock.js.erb just use jQuery code with <%= render :partial > =>%> where appropriate. >Lastly, I would recommend getting the PDF for "Agile Web Development with Rails 4th Ed" by Sam Ruby, Dave Thomas, et al from pragprog.com for additional information regarding the questions that you have above. Good luck, -Conrad> -- > 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On Thu, Jun 17, 2010 at 11:27 PM, Conrad Taylor <conradwt-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Thu, Jun 17, 2010 at 9:51 PM, Sharkie Landshark <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org>wrote: > >> I have been using link_to_remote forever now. I have also been using >> jquery through jrails. >> >> I am readying my code for Rails 3.0, and am wondering what is the best >> way to accomplish. >> >> For example, I have something like this all over in Rails 2.0 >> >> <%= link_to_remote "XXX", >> { :url => "/activities/hide_dock", :update => >> "dock-container", :complete => "fixDock()" }, { :class => "activities" } >> %> >> >> > Sharkie, I would recommend reading the following first before you start > upgrading from Rails 2.x to Rails 3.x: > > http://blog.peepcode.com/tutorials/2010/live-coding-rails-3-upgrade >Here''s another excellent reference that goes into greater detail of convert from Rails 2.x to Rails 3.x: http://www.railsupgradehandbook.com Good luck, -Conrad> > Next, link_to_remote has been deprecated in Rails 3 and you would > need to do the following: > > <%= link_to "XXX", { :remote => true }, { ... } %> > > >> def hide_dock >> render :partial => "/layouts/dock" >> end >> >> Now, in Rails 3.0 I am planning this >> >> <%= raw link_to "XXX", "/activities/hide_dock", >> {:remote => true, :class => "activities" } >> %> >> >> > Next, the above shouldn''t use raw because link_to method > returns an html_safe string in Rails 3. > > >> def hide_dock >> respond_to do |format| >> format.html >> format.js do >> ????? What do I put here ????? >> > > If you''re using RJS, then you''ll simple add > the expression to be executed. For example, > I tend to be partial to JSON and I would do the > following: > > format.js # render the action.js.rjs by default > > or you can redefine it as follows to return json > > format.js { render :json => @some_object } > > >> end >> end >> end >> >> > It''s not clear as to what you''re trying to do. The hide_dock is a > controller > action so do you want to allow the following: > > http://some_domain.com/controller_name/hide_dock > > >> My main question is since I am using jQuery, is there any point in using >> RJS? >> >> > If you intend on using jQuery, then there''s no need to use RJS. Just make > sure that you get the JS file here: > > http://github.com/rails/jquery-ujs > > >> Should I just have >> >> render :layout => false >> >> > If you''re updating just a part of the page, then you''ll need to use the > above. > > >> and in hide_dock.js.erb just use jQuery code with <%= render :partial >> =>%> where appropriate. >> > > Lastly, I would recommend getting the PDF for "Agile Web Development with > Rails 4th Ed" by Sam Ruby, Dave Thomas, et al from pragprog.com for > additional > information regarding the questions that you have above. > > Good luck, > > -Conrad > > >> -- >> >> 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org >> To unsubscribe from this group, send email to >> rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org<rubyonrails-talk%2Bunsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org> >> . >> For more options, visit this group at >> http://groups.google.com/group/rubyonrails-talk?hl=en. >> >> >-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.