0

hy

I have read à lot of question about this on stackoverflow or documentation and i didn't find my solution snif..

In my variable window.description i can see the content (window.description ="<span style="font-weight: bold;" ), he didn't display it and i dont understand why ??

 1.< script type="text/javascript">

           window.description  ='<%= @item.description %>';

 document.getElementById('editorResult').innerHTML = "<h2>Code display</h2><pre>" +     window.description+ "</pre>";

 <div id="editorResult">
   editorResult  =>
 </div>

1 Answer 1

1

Try using @item.description.html_safe. My guess is that rails is stripping out the HTML in your description.

You are probably going to run into a few issues with escaping. Just play around with html_safe and 'escape'/'unescape'.

Sign up to request clarification or add additional context in comments.

2 Comments

this doesn't work :( i really dont understand why he dont want to display my variable :(
What if you try <%= j @item.description.html_safe %> ? What is the output of this? the 'j' function is for javascript escaping.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.