简体   繁体   中英

simple_form hints as tooltip

I'm trying to have my simple_form hints appear as twitter-bootstrap tooltips, so that the hint only appears when the user selects the input field or hovers on it.

The form item would look like (in 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 

My CSS and Javascript for the hint of simple_form are vanilla, so I think I have to modify the config/initializers/simple_form.rb initializer file:

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

I solved it in this way:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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