简体   繁体   中英

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

Rendering a partial using AJAX

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

is my 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

Edit:

The AJAX update isn't working when there is more than one line in my partial. 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') %>');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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