Prevent double clicks on link_to_remote (simple case)

Posted . Visible to the public.

This works well in the simplified case, when your link disappears after it was clicked.

Let link_to_remote behave as „disabled“ after the first click. Use the :before hook to replace the orignal link with a link that does nothing but looks like the original link:

:ruby
  label = "do_something"
  dummy_link = link_to(label)
  other_attributes_hash = { :url => ..., :method => ..., ... }
  
  disable_link_option = { :before => "$('your_link_selector').html('#{escape_javascript(dummy_link)}'" } # jquery

= link_to_remote(label, other_attributes_hash.merge(disable_link_option);
Martin Straub
Last edit
License
Source code in this card is licensed under the MIT License.
Posted by Martin Straub to makandra dev (2013-02-07 15:50)