2014-07-07 55 views
0

我試圖讓我的simple_form提示顯示爲twitter-bootstrap工具提示,以便只有當用戶選擇輸入字段或懸停在其上時纔會顯示提示。simple_form提示爲工具提示

形式的項目看起來像(在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是香草的提示,所以我覺得我必須修改config/initializers/simple_form.rb初始化文件:

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

回答

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)