1
我正在使用rails 2.3並出現問題。 我有遠程表單,當我提交它時,我需要執行一些js。 這裏是我的js.erb文件在js.erb中渲染部分時出錯
$(document).ready(function() {
$("#block_login").remove();
$("#header").html("");
$("#header").html("<%= render :partial => "/layouts/header" %>");
});
在JS控制檯我有一個錯誤
> Uncaught SyntaxError: Unexpected identifier jquery.js:593
> jQuery.extend.globalEval jquery.js:593
> jQuery.ajaxSetup.converters.text script jquery.js:7175 ajaxConvert
> jquery.js:7074 done jquery.js:6622 jQuery.ajaxTransport.send.callback
,這是渲染的原因。
部分工作正常,因爲我已經在html中呈現它,並且一切都很好。 這裏是我的佈局/ _header
<div id="header">
<% if current_user.present? %>
<div class="icon_1"><%= link_to 'Выход', logout_path %>
<span>|</span><%= link_to 'Моя страница', user_path(current_user), :class => "registration" %> </div>
<% else %>
<div class="icon_1"><a href="#" onClick="block_login();">Вход</a>
<span>|</span><%= link_to 'Регистрация', new_user_path, :class => "registration" %></div>
<% end %>
<div class="clear"></div>
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="130px">
<div class="logo"><%= image_tag "/images/logo.png" %></div>
</td>
<td>
<div class="menu">
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td>
</td>
</tr>
</table>
</div>
</td>
</tr>
</table>
</div>
什麼,我做錯了什麼?提前致謝!
OT,但是,順便...... $( 「#頭」)HTML( 「」); $(「#header」)。html(「<%= render:partial =>」/ layouts/header「%>」); 第一個是無用的... –