CSS到button_to_remote rails功能

Gar*_*rth 1 ruby-on-rails

以下代码用于进行ajax调用的按钮.我试图将CSS添加到按钮无济于事.

<%= 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;
}
Run Code Online (Sandbox Code Playgroud)

这样做的正确方法是什么?

Leo*_*sov 5

button_to_remote需要两个参数哈希,所以第一个哈希必须明确地括在括号中.试试这个:

<%= button_to_remote "Close sales period", {:url=> {:controller=>'admin',:action=>"closure"}},:class=>"button close" %>
Run Code Online (Sandbox Code Playgroud)

(注意这对括号)

并且,请使用命名路线.