gpt4 book ai didi

javascript - simple_form 提示作为工具提示

转载 作者:太空宇宙 更新时间:2023-11-04 13:12:23 26 4
gpt4 key购买 nike

我正在尝试让我的 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)

关于javascript - simple_form 提示作为工具提示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24607917/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com