문제

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 ?

도움이 되었습니까?

해결책

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")) %>');
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top