Skip to content

Instantly share code, notes, and snippets.

@abachman
Created May 28, 2009 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save abachman/119558 to your computer and use it in GitHub Desktop.
Save abachman/119558 to your computer and use it in GitHub Desktop.
Ajax-y link disabling in Rails.
<!--
Imitate <%= submit_tag 'Perform an Action', :disable_with => "" %> button
using Rails' remote_function options.
Requires prototype.js, but could easily be written with any other js framework.
Not production tested.
-->
<span id='my_link'>
<%= link_to_remote "Perform an Action",
:url => { :controller => 'mycontroller', :action => 'ajax_action', :id => @this_item.id },
:before => "$('my_link').hide();$('my_message').show();",
:success => "$('my_link').show();$('my_message').hide();" %>
</span>
<span id='my_message' style='display:none'>
Loading...
</span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment