Robert Scott
2007-Jul-07 15:39 UTC
Is it possible to use link_to_remote with dynamic links?
As part of a search results page, I''m trying allow users of a particular application to view more details of individual products without 1) having to load a whole new page, 2) loading details through an IFRAME or 3) having to preload all of the product data into the results page. Ajax seemed to be an appropriate approach, so I created a blank layer called "product_details" which is hidden by default and setup the following code: <table> <% @products.in_groups_of(8, false) do |row_products| %> <tr> <% for product in row_products%> <td align="left" valign="top" width="100"> <%= link_to_remote( image_tag(''/images/sample.jpg''), :url => { :controller => ''store'', :action => ''results'' }, :update => "product_details", :complete => "new Effect.Appear(''animation'', { duration: 3.0 })" ) %> </td> <% end %> </tr> <% end %> </table> 1. How could I pass an individual product variable through this link - if at all - to the controller? 2. How can I use a variable in the link_to_remote tag? Specifically, the image will always be the ID of the product, but I can''t just insert product.id into the code. Thanks in advance! -- 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?hl=en -~----------~----~----~----~------~----~------~--~---
Shai Rosenfeld
2007-Jul-08 08:06 UTC
Re: Is it possible to use link_to_remote with dynamic links?
> <%= link_to_remote( image_tag(''/images/sample.jpg''), > :url => { :controller => ''store'', :action => ''results'' }, > :update => "product_details", > :complete => "new Effect.Appear(''animation'', { duration: 3.0 })" )> > 1. How could I pass an individual product variable through this link - > if at all - to the controller?...if you mean you want to pass a product object to the controller, u pass the object id to the controller, and find it, ie: :url => { :controller => ''store'', :action => ''results'', :prod_id => product.id },> 2. How can I use a variable in the link_to_remote tag? Specifically, the > image will always be the ID of the product, but I can''t just insert > product.id into the code.if you have an image per product, and want to display it use the "#{}" ruby string#eval thing <%= link_to_remote( image_tag("/images_path/prod_#{product.id}.jpg"), (i feel like i''m missing something in your request, but the above is the simplest thing that comes to my mind) hth -- 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?hl=en -~----------~----~----~----~------~----~------~--~---