Forum: Ruby on Rails link_to_remote possible with :class AND progress indicators?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Df0a460118ef876e45b13b8c1a471454?d=identicon&s=25 Marston A. (marstoni)
on 2006-04-30 02:13
I have the following code:

<code>

<span id="loader" style="display:none;">
<%= image_tag "spinner.gif" %></span>

<strong><%= link_to_remote('Add Entry', {:update => 'add-entry',
										:url => { :action => "show_add_entry" }},
										:loading => "Element.show('loader')",
										:complete => "Element.hide('loader')",
										:class => "create") %></strong>

</code>

It seems that I can either have a :class styling the link and not have
the progress indicators via :loading/:complete or the other way around
but not both.  It there a way to modify this code to have my link styled
via my class and also have the :loading/:complete callbacks work on
click as well?  Thanks.
Fb23bc8cd4030c526b0689276b34c8bd?d=identicon&s=25 Bryan Duxbury (bryanduxbury)
on 2006-04-30 15:42
Marston A. wrote:
> I have the following code:
>
> <code>
>
> <span id="loader" style="display:none;">
> <%= image_tag "spinner.gif" %></span>
>
> <strong><%= link_to_remote('Add Entry', {:update => 'add-entry',
> 										:url => { :action => "show_add_entry" }},
> 										:loading => "Element.show('loader')",
> 										:complete => "Element.hide('loader')",
> 										:class => "create") %></strong>
>
> </code>
>
> It seems that I can either have a :class styling the link and not have
> the progress indicators via :loading/:complete or the other way around
> but not both.  It there a way to modify this code to have my link styled
> via my class and also have the :loading/:complete callbacks work on
> click as well?  Thanks.

The problem with your code is that :class should be in another hash.
link_to_remote takes two hashes, options and html_options. By closing
the first hash (the one with :update), you're putting the loading and
complete ones into html_options. Try reorganizing your options a little
and it should work.
This topic is locked and can not be replied to.