how to prevent HAML from encoding my helper method
So I have this on my helper:
content_tag(:li, "All", { :onclick => %(hideAll(); document.getElementById("vl-body").children[0].style.display = "block") } )开发者_如何学C +
and HAML produced this:
<li onclick="hideAll(); document.getElementById("vl-body").children[0].style.display = "block"">All</li>
Can't have those encoded quotes. I wanted to use the % notation instead of the double quote so appreciate help with using the % that HAML won't encode it like that.
Thanks in advance.
#your view
%li#some_id
All
#application.js without jquery
document.getElementById('some_id').click(function(){
hideAll();
document.getElementById("vl-body").children[0].style.display = "block";
});
Alternative less opinionated answer:
content_tag(:li, "All", { :onclick => %(hideAll(); document.getElementById("vl-body").children[0].style.display = "block") } ).html_safe
I noticed the trailing plus in your content_tag code, is this important?
精彩评论