2009-09-09 37 views
1

下面的代碼是一個按鈕,使一個AJAX調用。我試圖添加CSS到按鈕無濟於事。CSS來button_to_remote軌功能

<%= 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; 
} 

這樣做的正確方法是什麼?

回答

5

button_to_remote需要則params的兩個散列,所以第一個哈希必須明確用括號括起來。試試這個:

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

(注意對括號)

而且,請使用命名路由信息。