![](/img/trans.png)
[英]Rails 4: Partial can't use javascript after being rendered (with ajax)
[英]Partial is not being updated after ajax call in Rails
在我的action.js.erb文件中
$("#performance").html("<%= escape_javascript(render 'performance_table',questions: @questions, groups: @groups, performances: @performances) %>")
在我看來
<div class="col-xs-5">
<div id="performance">
<%= render 'performance_table', :questions => @questions, :groups => @groups, :performances => @performances %>
</div>
</div>
在我的controller_action中
@groups = classroom.groups
@questions = @quiz.questions
@performances = Array.new
i = 0
group_ids.each do |g|
question_ids.each do |q|
@performances.push(Answer.where("group_id = ? AND question_id = ?",g,q).first.userans)
end
end
我正在對動作進行ajax調用,然后在action.js.erb文件中,我通過呈現相同的局部值(但具有更新的值)來更新div的html,但是partial不呈現更新的值。 請讓我知道我在做錯什么。 控制台也完全沒有顯示錯誤
嘗試在調用.html()之前和之后添加警報消息。 兩個警報都彈出嗎? 如果是這樣,則意味着問題很可能與您的JavaScript無關。
是的,這是一個問題請求,必須為“ js”類型,請提供您如何進行ajax調用? 那是其中的一部分
為什么要替換<div id="performance"> </div>
的現有值。 嘗試通過使用js中的append方法來附加新值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.