Question

I am making some ajax call and in my js.erb file I put

$("body").append(<%= escape_javascript(render("layouts/some_layout")) %>);

I had no output in my html file, but in my log, render("layouts/some_layout") is correctly called. So for debugging purpose, I put

 $("body").append(<%= j "<div>test</div>" %>);

But this also output nothin. Why is it so ?

Was it helpful?

Solution

I guess you should have your erb code enveloped with quotation marks, otherwise you'll probably get JS syntax error:

$("body").append('<%= escape_javascript(render("layouts/some_layout")) %>');
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top