簡體   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