zyriuse
zyriuse

Reputation: 73

for get a ruby variable in javascript

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>

Upvotes: 0

Views: 79

Answers (1)

CambridgeMike
CambridgeMike

Reputation: 4622

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'.

Upvotes: 1

Related Questions