link_to_remote html_options example

Can anyone give me an example of using html_options with
link_to_remote? I'd like to set (for instance) the CSS Class on the
resulting link. I've tried this sort of thing:

<%= link_to_remote 'Text', :url => {:action => 'myaction', :id =>
myobject.id}, :html_options => {:class => 'myclass'} %>

Everything works OK except that it ignores the HTML options.

Thanks,
Cliffe

cliffeh wrote:

Can anyone give me an example of using html_options with
link_to_remote? I'd like to set (for instance) the CSS Class on the
resulting link. I've tried this sort of thing:

<%= link_to_remote 'Text', :url => {:action => 'myaction', :id =>
myobject.id}, :html_options => {:class => 'myclass'} %>

drop the :html_options => part...
eg.

<%= link_to_remote 'Text', :url => {:action => 'myaction', :id => myobject.id}, :class => 'myclass' %>

I think that should work...
G

Can anyone give me an example of using html_options with
link_to_remote? I'd like to set (for instance) the CSS Class on the
resulting link. I've tried this sort of thing:

<%= link_to_remote 'Text', :url => {:action => 'myaction', :id =>
myobject.id}, :html_options => {:class => 'myclass'} %>

In your case Rails cannot tell where does options parameter hash end and
html_options hash begins.

Try that:

<%= link_to_remote 'Text', {:url => {:action => 'myaction', :id =>
myobject.id}}, {:class => 'myclass'} %>

Regards,
Rimantas

drop the :html_options => part...
eg.

<%= link_to_remote 'Text', :url => {:action => 'myaction', :id => myobject.id}, :class => 'myclass' %>

I think that should work...

You are right about :html_options, but this still will not work,
because 'options' hash will
swallow both :url and :class leaving 'html_options' empty.
When using html_options, make sure Rails can tell them from options,
i.e. use curly
braces for options:

<%= link_to_remote 'Text', {:url => {:action => 'myaction', :id =>
myobject.id}}, :class => 'myclass' %>

Regards,
Rimantas