Why escape_javascript before rendering a partial?(为什么在渲染部分之前使用 escape_javascript?)
问题描述
I'm looking at this Railscast episode and wondering why the call to escape_javascript
is needed here:
$("#reviews").append("<%= escape_javascript(render(:partial => @review)) %>");
What is escape_javascript
used for?
According to the Rails docs:
escape_javascript(javascript)
Escape carrier returns and single and double quotes for JavaScript segments.
But that doesn't mean much to me.
Because you don't want users posting JavaScript that the browser actually executes?
这篇关于为什么在渲染部分之前使用 escape_javascript?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!