[英]JavaScript from .js.erb is executed but is also displayed as text
I have a form in a popup window like this: 我在这样的弹出窗口中有一个表单:
<%= form_tag "/controller/action", :method => :get, :remote => true do %>
...
<% end %>
In my controller: 在我的控制器中:
respond_to do |format|
format.js
end
After submitting I am trying to change elements of parent window in action.js.erb
: 提交后,我试图在action.js.erb
更改父窗口的元素:
window.opener.$('#some-div').html('<div class="flash notice">...</div>');
Or without jQuery: 还是没有jQuery:
window.opener.document.getElementById('some-div').innerHTML = '<div class="flash notice">...</div>';
In both cases I get the flash message in my div as I wanted plus the whole content of action.js.erb as text. 在这两种情况下,我都会根据需要在div中获得Flash消息,以及将action.js.erb的全部内容作为文本。
What am I doing wrong? 我究竟做错了什么?
我猜想Rails会将您的文字转义。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.