繁体   English   中英

simple_form提示作为工具提示

[英]simple_form hints as tooltip

我试图将我的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 

我的用于simple_form提示的CSS和Javascript很普通,所以我认为我必须修改config/initializers/simple_form.rb初始化程序文件:

b.use :hint,  :wrap_with => { :tag => :span, :class => :hint }

我是这样解决的:

    :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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM