简体   繁体   English

Rails simple_form输入上的自举弹出窗口

[英]Bootstrap popovers on Rails simple_form inputs

I'm trying to show some popovers in a form I am currently building. 我正在尝试以当前正在构建的形式显示一些弹出窗口。 They should appear when the user has focus on a specific field, but I can't quite manage to do so, here is what I got (in Slim): 当用户专注于特定领域时,它们应该出现,但是我做不到,这是我得到的(在Slim中):

#sample_form=simple_form_for sample do |form|
    =form.input :sample_name, placeholder: "Name", rel="popover" data-content="content" data-original-title="title"

javascript:
    $('#sample_form input').hover(function()
        {
            $(this).popover('show')
        });

And here is what I get when I try to load the page: 这是我尝试加载页面时得到的:

..._form.html.slim:4: syntax error, unexpected tIDENTIFIER, expecting tASSOC
...", rel="popover" data-content="lol" data-original-...
...                     ^
..._form.html.slim:4: syntax error, unexpected tIDENTIFIER, expecting ')'
...opover" data-content="content" data-original-title="title"))).to_...
...                                   ^

Probably a simple syntax mistake but I can't figure it out. 可能是一个简单的语法错误,但我无法弄清楚。

Thanks in advance. 提前致谢。

The problem is that you are mixing Slim and Ruby together on the second line. 问题是您在第二行将Slim和Ruby混合在一起。 Try something like this instead: 尝试这样的事情:

= form.input :sample_name, placeholder: "Name", :input_html => {:rel => "popover", :data => {:content => "content", "original-title" => "title"}}

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

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