问题描述
这来自 Twitter Bootstrap modal rails 删除按钮不起作用一个>
如何传递 html 代码以在 Twitter Bootstrap 模式中显示?这是链接
How can I pass html code to show in Twitter Bootstrap modal? Here is the link
<%= link_to t('delete'), post, method: :delete, confirm: t('delete_this_question'), 'data-my-message' => raw(post.text), class: 'label' %>
post.text 是 HTML 代码.现在它以错误的格式显示链接.
post.text is HTML code. Now it shows link in bad format.
谢谢
推荐答案
我认为这里的问题可能是你对raw"的使用.如果您在 link_to 助手中使用原始 html,它可能会弄乱链接的引用.例如,您可能会得到这样的信息:
I think the problem here is probably your use of "raw". If you use raw html inside your link_to helper it will probably mess up the link's quoting. For example you might get something like this:
<a href="..." data-my-message="Hello <a href="/foo">world</a>" ...>
这会弄乱你的链接标签.我不确定您的其余视图如何组合在一起,但我认为您应该能够放弃原始"方法:
And that would mess up your link tag. I'm not sure how the rest of your view fits together but I think you should just be able to drop the 'raw' method:
<%= link_to t('delete'), post, method: :delete, confirm: t('delete_this_question'), 'data-my-message' => post.text, class: 'label' %>
这篇关于twitter bootstrap 模态数据属性参数中的 html 文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!