简体   繁体   English

当部分中有多行时,AJAX无法正常工作

[英]AJAX not working when more than one line is in the partial

Rendering a partial using AJAX 使用AJAX渲染部分

$('#next_videos').replaceWith('<%= render(:partial => 'videos')%>');

is my js 是我的js

the partial im rendering i dumbed down to isolate the problem 部分我渲染我愚蠢地隔离问题

<p> Testing </p>

so this works fine but when you add any ruby comments eg 所以这很好,但是当你添加任何红宝石评论时,例如

<p> Testing </p>
<%# holder = videos_counter %>

nothing happens. 什么都没发生。 The server shows that it processes it fine but no changes occur on the web page. 服务器显示它处理得很好,但网页上没有发生任何变化。 Any clue as to what's going on here? 关于这里发生了什么的任何线索? Thanks. 谢谢。

Using rails 3.1.1, sqlite3, formtastic 2.0.2, devise 1.5.1, and whenever 使用rails 3.1.1,sqlite3,formtastic 2.0.2,设计1.5.1,并随时

Edit: 编辑:

The AJAX update isn't working when there is more than one line in my partial. 当我的部分中有多行时,AJAX更新无效。 For example, 例如,

<p> Testing </p> <p> Testing </p>

will work but 会工作但是

<p> Testing </p>
<p> Testing </p>

will not. 将不会。

您可以尝试使用escape_javascript帮助程序或其j别名来转义标记:

$('#next_videos').replaceWith('<%=j render(:partial => 'videos') %>');

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM