best_in_place gem:样式确定按钮

best_in_place运行良好,但我想使用fontawesome图标作为可选的“确定”按钮,而不是字符串。 如何在:ok_button哈希中合并''.html_safe语法?

  = best_in_place @book, :default_price_amount, :html_attrs => {:class => 'medium_no_dropdown'}, :ok_button => "OK" 

这是一个老问题,现在使用:ok_button_class选项在best_in_place gem中支持所需的function。 用法是这样的:

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

有一个解决方案,但不完全是为ok_button添加样式。 如果您不介意使用unicode字形,可以尝试:

 = best_in_place @book, :default_price_amount, :html_attrs => {:class => 'medium_no_dropdown'}, :ok_button => "✓".html_safe 

包含所有unicode字符的表可能是您对另一个变体的引用。

ok_button的真实样式的问题在于散列仅接受数据属性以定义按钮。 可能在下一版本的BIP中,这将得到改进。

在源代码中,创建按钮的位置(best_in_place.js):

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

‘value’是我们传递哈希的东西。 如果有一种方法可以引用由awesome字体定义的字形代码( 对于icon-ok),它会很漂亮。