我尝试将simple_form
提示显示为twitter-bootstrap工具提示,以便只有当用户选择输入字段或悬停在其上时才会显示提示。
表单项看起来像(以haml为单位):
:ruby
title = <<TITLE
This text is normally hidden and pops up as a bootstrap tooltip
only when the user hovers on the input field.
TITLE
= f.input :opt_out, hint: title
我的CSS和Javascript提示simple_form是vanilla,所以我想我必须修改config/initializers/simple_form.rb
初始化文件:
b.use :hint, :wrap_with => { :tag => :span, :class => :hint }
答案 0 :(得分:1)
我用这种方式解决了它:
:ruby
title = <<TIT
This text is normally hidden and pops up as a bootstrap tooltip
only when the user hovers on the input field.
TIT
link = link_to "what's this?", "", rel: "tooltip", title: title, data: {placement: "right"}
label = "Opt out #{link}"
= f.input :opt_out, label: raw(label)