Monday, May 07, 2007

How to pass a class or id to link_to_remote

This does seem like a really simple thing now that I figured out how to do it.
<%= link_to_remote 'Name',
{:url => {:controller => 'some_controller', :action =>'some_action', :id => some_id}},{ :class => 'some_class' }-%>

If you want to specify a fall back url for href instead of the default # you can put that in the html_options part also.
<%= link_to_remote 'Name',
{:url => {:controller => 'some_controller', :action => 'some_action', :id => some_id}},
{:class => 'some_class', :href => url_for({:controller => 'some_controller', :action => 'some_action', :id => some_id}) }-%>

No comments: