0
버튼 클릭으로 부분 업데이트를 시도하고 있습니다. 부분이 이미 뷰에 있습니다. 클릭에 부분 업데이트 버튼 클릭
<div id="partial_to_update">
<%= render partial: "accounts/all_accounts", :locals => { term: @term} %>
</div>
, 나는 '용어'의 값을 변경하고 같은 부분을 다시 렌더링 할 (갱신 부분 링크를 말할 수 있습니다).
<%= link_to "Update Partial", update_accounts_path, :remote => true, id: "update-partial-link" %>
는 루트에, 나는 추가 :보기/계정/update_accounts.js.erb에서
def update_accounts
respond_to do |format|
format.js
end
end
: accounts_controller에서
get '/update_accounts' => "accounts#update_accounts", as: :update_accounts
$('#partial_to_update').replaceWith("<%= escape_javascript(render partial: 'accounts/all_accounts', :locals => { term: 'new_term'}) %>");
하지만, "부분 업데이트"를 클릭하면 부분적으로 사라진다. replaceWith ("MY NAME")을 사용하면 작동합니다.
어떤 도움 ??
어떻게 부분적으로 보이는지 보여 줄 수 있습니까? – kasperite
나는 당신이 update_accounts 액션에서 @new_term 인스턴스 변수를 update_accounts.js.erb 파일로 전달하지 않는다고 생각한다. –