Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

render html from javascript rails

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.

like image 753
lguenier Avatar asked Mar 02 '26 11:03

lguenier


1 Answers

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

$('.modal-body').html('#{j render partial: 'details'}');  // in HAML
like image 142
Emu Avatar answered Mar 03 '26 23:03

Emu