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
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
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.