Created
May 28, 2009 20:43
-
-
Save abachman/119558 to your computer and use it in GitHub Desktop.
Ajax-y link disabling in Rails.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- | |
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