我在 Rails 3.2.1 中使用 Simple_form
一切正常,除了我需要为 Bootstrap 弹出窗口的 input_html 设置“data-content”属性
但是,当我使用以下 Rails/Ruby 时,我不喜欢这些代码,因为“data-content”方法中有一个破折号:
<%= f.input :first_name, :required => true, :label => "First Name", :autofocus => true, :input_html => {:rel => "tooltip", :title => "Testing!", :data-content => "Popover content"}
我得到一个错误:
undefined local variable or method `content'
有谁知道如何使用 simple_form 为输入元素设置数据内容???
谢谢
最佳答案
你不能在 ruby 符号中使用 -
但你可以使用像 "data-content"
这样的字符串。所以,这可能会起作用:
<%= f.input :first_name, :required => true, :label => "First Name", :autofocus => true, :input_html => {:rel => "tooltip", :title => "Testing!", 'data-content'=> "Popover content"}
关于javascript - 使用 simple_form 设置数据内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10063137/