Ajax link_to_remote replace with spinner on click
This combination of CSS and prototype allows you to swap out the text with a spinner element, then back when loading is complete.
CSS
RHTML
Upon link click, the loading class will be added, moving the text off the window, effectively hiding it, while showing the background (not background-image). When XHR call is complete, simply remove the class and you're back to normal display properties.
CSS
div.loading { background: url(/images/dots-white.gif) no-repeat 8px 6px; text-indent: -999px; }
RHTML
<div id="lc" class=""> <%= link_to_remote 'toggle action', { :url => toggle_showall_new_recipe_path, :method => :get, :before => "Element.addClassName('lc', 'loading')", :complete => "Element.removeClassName('lc', 'loading')"}, :class => 'loading xhr', :id => 'xhr-link' %> </div>
Upon link click, the loading class will be added, moving the text off the window, effectively hiding it, while showing the background (not background-image). When XHR call is complete, simply remove the class and you're back to normal display properties.