SitePoint Sponsor

User Tag List

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

    Is it accessible to use rails buttons?

    We all know that we should do POST requests whenever in our application we trigger a "destructive" action. This beacause it is the appropriate HTTP verb and 'cause search engine/spider/crawlers won't follow/trigger this POST links or html form buttons. Rails has the button_to helper to generate a form with just a single submit element to use as a POST link. We can also use a normal link_to helper to generate a normal <a> link element and then with a parameter to that helper method we can turn that link default behaviour from GET to POST. Now i wonder what is the best method to implement a POST request in a rails application. In particular i would like to know if it is better to use normal <a> elements (with javascript to turn that link request from GET to POST with the help of rails helper) instead of buttons (button_to helper), and this from a usability/accessibility perspective.

  2. #2
    SitePoint Guru silver trophy Luke Redpath's Avatar
    Join Date
    Mar 2003
    Location
    London
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For the most common use case of Delete links, it is perfectly possible to use a link instead of a button and maintain the use of POST (well, DELETE in an ideal world) using Javascript but keep things accessible for those not using Javascript.

    I would have it so that the link by default (no js) links to an intermediate confirmation page ("are you sure you want to delete this?") with a form and a button to finalise the delete. You would then augment this link using JS to capture the same functionality only on the same page (an alert box provides the confirm dialog then AJAX fires off the delete request).


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
  •