views:

371

answers:

1

Hi,

The following code is for a button to make a ajax call. I am trying to add css to the button to no avail.

<%= button_to_remote "Close sales period",:url=>{:controller=>'admin',:action=>"closure"},:class=>"button close" %>

.close_sales_period { background: url(/images/buttons/close_sales_period.gif) no-repeat; }

.button { padding:0; border:0; width:152px; height:26px; font-size:0px; cursor:pointer; text-indent:-9999px; text-transform: capitalize; color:transparent; display:inline; background-repeat:no-repeat; }

What is the correct way to do this?Any hints.

+3  A: 

button_to_remote need two hashes of params, so the first hash must be explicitly enclosed in brackets. Try this:

<%= button_to_remote "Close sales period", {:url=> {:controller=>'admin',:action=>"closure"}},:class=>"button close" %>

(note the pair of brackets)

And, please, use named routes.

Leonid Shevtsov