best_in_place gem:样式确定按钮

时间:2012-12-21 22:50:29

标签: ruby-on-rails font-awesome

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

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

3 个答案:

答案 0 :(得分:4)

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

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

答案 1 :(得分: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)
    )
  }

'value'是我们传递的哈希值。如果有一种方法来引用字形码,由令人敬畏的字体(&#xf00c;为icon-ok)定义,它将是美丽的。

答案 2 :(得分:1)

由于我花了几个小时来做​​同样的事情,所以我发现我们可以覆盖this function的原型来创建IP Address restriction blocking it而不是<button>。但是,activateForm function仅等待来自<input type="button">的点击事件,并且由于我无法覆盖它,因此我尝试了另一种方法(有点脏)–并且可行。

在另一个js标签/文件上覆盖此脚本

input[type="button"]