我在我的项目中使用过haml。通过向example.js.haml中添加以下代码行,将返回<h1>hello</h1>而不是hello
:plain
document.getElementById('light').append("#{escape_javascript(raw '<h1>hello</h1>')}"); 需要关于如何对example.js.haml进行周访问的建议,以便只返回没有html标记的hello
发布于 2016-11-30 12:56:08
这对我来说很管用:
:plain
$('#light').append("#{escape_javascript('<h1>hello</h1>'.html_safe)}"); 因此,问题似乎在代码中的其他地方。
请出示你的控制器
发布于 2016-12-01 03:03:11
这是由于Jquery冲突造成的。
添加jquery.noconflict.js
(function() { window.$jq = jQuery.noConflict(); })();改变了example.js.haml
:plain
$jq('#light').append("#{escape_javascript('<h1>hello</h1>'.html_safe)}"); 发布于 2016-11-30 12:46:01
你试过删除'raw‘关键字吗?:)
https://stackoverflow.com/questions/40888280
复制相似问题