0

I am using jQuery in my Rails project to respond to an AJAX call. I want to replace some html with the updated html (from a partial).

$('#cart').html('<%= render(@cart) %>')

This doesn't work, and when I check FireBug, it expands out to:

$('#cart').html('<h1>multiple
    lines
    <a href="of">html</a>
    </h1>')

1 Answer 1

1

Try:

$('#cart').html('<%= escape_javascript(render(@cart)).html_safe %>')
Sign up to request clarification or add additional context in comments.

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.