SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Advanced interface to a list of active record objects...

    I would like to do a different list of items in a database than the normal we see around. In essence i have one item per line and i should have a way to select only one of those items in the list and then once selected i can click at the end of the page one of the actions: "show", "edit" or "delete" based on the item i have checked, instead of repeting those action links on every line per item.
    I thought that each item line could be a radio button and when i click a radio button (actually an item in the list) i send an ajax request that modifies accordingly the 3 links at the bottom of the page with the right item IDs.
    Is this a possible or correct solution? I don't know if a list of database item in a form (a series of radiobuttons) is a bad way of doing that and maybe it is too heavy whene there are a lots of items.

  2. #2
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can set a javascript onclick for the links that changes the action of the form and submits it.

    Why do you want to have only 3 links?

  3. #3
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Fenrir2 View Post
    You can set a javascript onclick for the links that changes the action of the form and submits it.

    Why do you want to have only 3 links?
    yes that would be much more simple. Is this anyway good design? Having a list of database items in a possibily very large form?
    I would like to have only three links to do a cleaner interface.
    Could you please post some example code to to that?

  4. #4
    SitePoint Guru Skyblaze's Avatar
    Join Date
    Jul 2005
    Location
    Italy
    Posts
    734
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in my way you can for example check several users (line item) to delete and then press one time the delete button. Anyway is this bad design for a list of items in a database? Must i have to follow the traditional way of putting the crud operation links on every item line?

  5. #5
    SitePoint Guru
    Join Date
    Aug 2005
    Posts
    986
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I prefer 3 links per item because you don't have to click as much that way.

    Code:
    <ul>
    <&#37; for user in @users %>
    <li>
      <%= link_to user.name, user_url(user) %>  <!-- show -->
      <%= link_to 'edit', edit_user_url(user) %> <!-- edit -->
      <%= link_to 'destroy', user_url(user), :method => :delete %> <!-- delete -->
    </li>
    <% end %>
    </ul>
    Check out "script/generate scaffold_resource".

    You can also add Ajax for improved user experience.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •