Js.erb render html string

24 views
Skip to first unread message

Gm

unread,
Apr 22, 2015, 3:21:17 PM4/22/15
to rubyonra...@googlegroups.com
Hi,

I have an action that renders a simple text:

text.js.erb
modal.find('.modal-body').text('<%= @text.content %>');

This content variable contains a string with some html tags.
But these tags aren't displayed correct.
I tried to use raw, html_safe, etc
But nothing worked.

How can I display the content with html tags formated ?

example: <strong>my text</strong>

my text

Thanks.

Vladimir Gordeev

unread,
Apr 22, 2015, 3:26:40 PM4/22/15
to rubyonra...@googlegroups.com
Gosh, I mean method .html() instead of method .text()

On Wed, Apr 22, 2015 at 9:25 PM, Vladimir Gordeev <gordeev.v...@gmail.com> wrote:
You should use method .content() instead of method .text()

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/1d20fcb4-3fde-4d6f-ac86-f2de80ae9f2e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Vladimir Gordeev

unread,
Apr 22, 2015, 3:26:40 PM4/22/15
to rubyonra...@googlegroups.com
You should use method .content() instead of method .text()
On Wed, Apr 22, 2015 at 9:21 PM, Gm <javap...@gmail.com> wrote:

--

Gm

unread,
Apr 22, 2015, 3:42:16 PM4/22/15
to rubyonra...@googlegroups.com
I  owe a donut to you.
Thank you man.

Vladimir Gordeev

unread,
Apr 22, 2015, 4:04:21 PM4/22/15
to rubyonra...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages