3

I Have a rendering of a partial that should be outputted to a div that is not displayed correctly. I tried in my index.js.haml :

= "$('.modal-body').html('#{escape_javascript(raw render("details"))}');"
= "$('.modal-body').html('#{escape_javascript(raw render("details")).html_safe}');"
= "$('.modal-body').html('#{escape_javascript(raw render("details").html_safe)}');"
= "$('.modal-body').html('#{raw escape_javascript(raw render("details"))}');"
= "$('.modal-body').html('#{raw escape_javascript(raw render("details").html_safe)}');"
= "$('.modal-body').html('#{raw escape_javascript(raw render("details")).html_safe}');"

and they are all outputing the same following thing:

enter image description here

If I remove the escape_javascript, it ain't working anymore.

3
  • Try this = $('.modal-body').html('#{escape_javascript(raw render("details")).html_safe}'); Commented Jul 5, 2015 at 16:24
  • I'm searching for solution. Mark accepted if you found answer. Commented Jul 5, 2015 at 16:41
  • I can't accept my answer before two days... But look at my answer, it is working Commented Jul 5, 2015 at 16:42

2 Answers 2

1
$('.modal-body').html('<%=j render partial: 'details' %>'); // in HTML

$('.modal-body').html('#{j render partial: 'details'}');  // in HAML
Sign up to request clarification or add additional context in comments.

1 Comment

You have to add the :plain before and indent the haml line
1

Thanks to Emu who posted the answer in ERB I found a way of doing it in haml:

:plain
  $('.modal-body').html('#{j render partial: 'details'}'); // in HAML

$('.modal-body').html('<%= j render partial: 'details'%>'); //in ERB

Comments

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.