Reputation: 7011
I'm trying to handle the content of a bunch of divs with jQuery. It works perfectly except for the fact that when the HTML is placed inside a visible div
it won't render elements like <h3>
or <br>
as HTML, they just end up being displayed as code. Any thoughts? I've tried messing around with Rails' h(this)
or this.html_safe
, neither of which seem to work.
This code makes the hidden 'storage' divs:
<div style="display: none;"><%= content_tag(:div, r.body.html_safe, :id => 'page'+i.to_s+'_hidden_article'+r.issue_id.to_s) %></div>
This code displays one of the above to the user:
<%= content_tag(:div, "", :id => "document_article#{i}_body", :class => "thumbnail") %>
And this is the jQuery that manages it the exchanges:
$('#doc_article1').change(function() {
var src = $(this).val();
$('#document_article1_body').text('');
var b = $('#page1_hidden_article'+src).text();
$('#document_article1_body').text(b);
});
Any help would be excellent.
Cheers!
Upvotes: 0
Views: 48