【发布时间】:2012-01-19 15:01:32
【问题描述】:
我在 Rails 3.1.3 应用程序中使用 Twitter-Bootstrap。我有许多带有弹出框的元素,例如:
<a data-original-title="Quality" rel="popover" data-content="Did they do a good job? 5 for Really Nice, 4 for Good Enough, 3 for Average, 2 for Somewhat OK, 1 for Really Bad">Q</a>
我想在内容部分有一个有序列表,类似于:
<OL reversed="reversed">
<LI> for Really Nice </LI>
<LI> for Good Enough </LI>
...
</OL>
有没有不修改 JavaScript 的简单方法?无论我尝试什么,html 代码都会显示在浏览器上,而不是被解释为这样。
更新
按照大卫的建议使用以下代码
link_to 'Q', '#', options: { data-original-title: "Quality", rel: 'popover', data-content: "Did they do a good job? <ol><li> for Really Nice </li><li>...</li></ol>".html_safe }
使用我的设置生成语法错误。我认为这解释了原因:Ruby 1.9 hash with a dash in a key。所以我正在使用:
<%= link_to 'Q', '#', options: { :"data-original-title" => "Quality", :rel => 'popover', :"data-content" => "Did they do a good job? <ol><li> for Really Nice </li></ol>".html_safe } %>
这不起作用。它会生成以下 HTML:
<a href="#" options="{:"data-original-title"=>"Quality", :rel=>"popover", :"data-content"=>"Did they do a good job? <ol><li> for Really Nice </li></ol>"}">Q</a>
【问题讨论】:
标签: javascript ruby-on-rails twitter-bootstrap