lunaclaire
2010-Jan-24 00:57 UTC
link_to helper (or some other method) on an entire table row?
I''m trying to implement a design handed to me where an entire row of a table is a link to view details about the obj shown in that row. The html handed to me looks like this: <tr onmouseover="this.style.cursor=''pointer'';" onclick="location.href=''new_page.html'';" style="cursor: pointer;"> <td class="checkbox"><input type="checkbox" name="option1"></td> <td class="name">Person''s Name</td> <td class="details"><b>Home:</b>Person''s Email</td> </tr> note the ''onclick'' in the <tr> Is there a Rails Way to do this? -- 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.
lunaclaire
2010-Jan-24 01:02 UTC
Re: link_to helper (or some other method) on an entire table row?
Never mind. It just dawned on me... For others who may wonder: <tr onmouseover="this.style.cursor=''pointer'';" onclick="location.href=''<%= url_for([@user, contact]) %>'';" style="cursor: pointer;"> Note the url_for call (in this case on a nested resource) On Jan 23, 4:57 pm, lunaclaire <szager...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m trying to implement a design handed to me where an entire row of a > table is a link to view details about the obj shown in that row. > > The html handed to me looks like this: > > <tr onmouseover="this.style.cursor=''pointer'';" > onclick="location.href=''new_page.html'';" style="cursor: pointer;"> > <td class="checkbox"><input type="checkbox" name="option1"></td> > <td class="name">Person''s Name</td> > <td class="details"><b>Home:</b>Person''s Email</td> > </tr> > > note the ''onclick'' in the <tr> > > Is there a Rails Way to do this?-- 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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Marnen Laibow-Koser
2010-Jan-24 07:21 UTC
Re: link_to helper (or some other method) on an entire table
lunaclaire wrote:> Never mind. It just dawned on me... For others who may wonder: > > <tr onmouseover="this.style.cursor=''pointer'';" > onclick="location.href=''<%= url_for([@user, contact]) %>'';" > style="cursor: pointer;">Wow! I realize that this HTML was handed to you, but please, never do it this way. Problems which you should correct in the interests of cleaner markup and better maintainability: * Inline CSS. Banish the HTML ''style'' attribute from your repertoire. Do all styling with class names. That goes likewise for the styles you call from your JavaScript code -- it''s better to set this.className than this.style. * Inline JavaScript. HTML should contain *only* information about the logical structure of a document. Styling belongs in a separate CSS file, and by the same token, behavior belongs in a separate JavaScript file. This has the added benefit of allowing you to use JavaScript like a real programming language (which it is!), not an extension bolted onto HTML. * (Potential) lack of degradation. Always try to provide an alternative for use when JavaScript is not available. In this case, that probably means that you want to make sure some element within the table row in question is wrapped in an <a href> tag. (In your case, that''s probably best done on the name column.) If you have any questions about how to do any of these things, let me know.> > Note the url_for call (in this case on a nested resource)Best, -- Marnen Laibow-Koser http://www.marnen.org marnen-sbuyVjPbboAdnm+yROfE0A@public.gmane.org -- 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.