2012-12-21 24 views

回答

3

這是一個老問題,現在使用ok_button_class選項在best_in_place gem中支持所需的功能。用法是這樣的:

<%= best_in_place @post, :title, :ok_button => "Submit", :ok_button_class => "btn post-title" %> 
1

有一種解決方案,但不完全是爲了向ok_button添加樣式。如果你不介意使用unicode字形,你可以試試:

= best_in_place @book, :default_price_amount, :html_attrs => {:class => 'medium_no_dropdown'}, :ok_button => "&#x2713;".html_safe 

The table with all the unicode字符可能是你的另一種變體的參考。

ok_button的真實樣式的問題是散列只接受數據屬性只用於定義按鈕。可能在BIP的下一個版本中,這將得到改進。

在源代碼,其中該按鈕被創建(best_in_place.js):

if(this.okButton) { 
    output.append(
     jQuery(document.createElement('input')) 
     .attr('type', 'submit') 
     .attr('value', this.okButton) 
    ) 
    } 

「價值」是我們通過對散列。如果有一種方法可以參考由真棒字體(&#xf00c; for icon-ok)定義的字形代碼,它會很漂亮。

+0

我只是需要「html_attrs」,感謝它的作品像魅力:) – SSR