tags:

views:

88

answers:

1

I have the following haml code:

- @theLinks.each_index do |x|
   %br
   %form{:action=>'/Download', :method=>"post",:enctype=>"multipart/form-data"}
     %input{:type=>"submit", :name=>"#{@theLinks[x].url}", :value=>"Name: #{@theLinks[x].Name} Study Time: #{@theLinks[x].studyTime} Comments: #{@theLinks[x].comments}"}

Basically, for each person, list the time they participated in a study and the comments on the study. Right now, this renders as a set of buttons. I'd like to render it as a table, with each row clickable in the same way (ie, using the 'post' method, so that only the haml file has to be edited without touching the rest of the files).

Ideally, I'd also like to be able to sort the table by name, time, or comments, but that might be getting ahead of myself.

So how can I change this list of buttons into a table with clickable rows?

A: 

Okay, how about this code? This makes a table with three columns, one for the name(clickable buttons like what you did), one for the time spent, and one for comments. Time and comments are just plain text, so only the name is clickable. In the future, if you want to add sorting, just convert the table headers to links that have ajax functions in them for sorting. I think jQuery has a function/plugin for sorting tables so you can just look into their doc(if you use jquery)

%table
  %tr
    %th Name
    %th Time spent
    %th Comments
  - @theLinks.each do |link|
    %tr
      %td
        %form{:action=>'/Download', :method=>"post",:enctype=>"multipart/form-data"}
          %input{:type=>"submit", :name=>"#{link.url}", :value=>"Name: #{link.Name}}"
      %td= "Study Time: #{link.studyTime}"
      %td= "Comments: #{link.comments}"
corroded
@corroded-- I don't want a table with one column, I want it with three. The use of the form/button is right now a hack since I can't directly link to the files to be downloaded, but instead have to interpret the button click to acquire the data from another server that can't be seen from the outside world (ie, direct linking is useless, since that other server is internal and has no external ip). I would also rather that only the name be the download link, or a big obvious button that says 'download'. And can I sort the list if I use li like that?
mmr
hey there, changed my answer to reflect the clarifications you did. Is that what you are trying to do?
corroded