DRY up multiple calls link_to_remote?

I have the following code that will be repeated many times in a
single .rthml page.

<%=link_to_remote(“Test AJAX”,
:update => ‘chart’,
:url => url_for(:controller => ‘chart’, :action =>
‘linear_graph’),
:loading => "Element.show(‘loading’); ",
:complete => “Element.hide(‘loading’)”,
:before => “this.parentNode.className = ‘myclass’;”) %>

What is the best way to DRY this up so
the :loading, :complete:, :before: and :update callbacks are reused? I
want to avoid changing all instances of this call when I update the
code. The only parameter that will change is :url

On 9/5/07, chirag [email protected] wrote:

:before => "this.parentNode.className = 'myclass';") %>

What is the best way to DRY this up so
the :loading, :complete:, :before: and :update callbacks are reused? I
want to avoid changing all instances of this call when I update the
code. The only parameter that will change is :url

I use something like the following:

in application_helper.rb:
def showing_progress(opts={}, hide_div = nil)
opts.merge :loading => update_page{|p| p[hide_div].hide if
hide_div; p[:progress].visual_effect(:appear, :duration => 0.5); },
:complete => update_page{|p| p[:progress].hide; p[hide_div].show
if hide_div; }
end

in my view.rhtml:
<%= link_to_remote(h(email.subject), showing_progress({:url =>
{:action => ‘display_email’, :id => email}}, ‘email_content’)) %>

Adam