On 16.7.2005, at 20:36, Shelby Westman wrote:
>> What is the proper syntax to apply a css class to a link created using
>> link_to?
>>
>
> <%= link_to ("remove", {:action =>
"remove_piece", :id =>
> @repertoire_list.id, :piece_to_remove => replist_piece.id}, {:class
=>
> ''linkCommand'', :confirm => "Are you sure? This
will remove this
> piece."}) %>
>
> This works. Must be the extra braces...
Right. The reason is that link_to takes normally three parameters [1]:
name, options and html_options, of which the two latter are hashes.
Therefore, if you use html_options (the stuff that come into the anchor
tag, like class, id etc), you *need* to use the curly braces to
separate the two hashes. Otherwise all key => value pairs are
considered to be part of the first (options) hash.
//jarkko
[1]
http://raildock.mytechsupport.com/ri/ActionView::Helpers::
UrlHelper@link_to
--
Jarkko Laine
http://jlaine.net
http://odesign.fi
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails