Newer
Older
dmpopidor / app / views / answers / update.js.erb
@ray.carrick ray.carrick on 28 Mar 2017 647 bytes Change notes to work with AJAX calls.
// after saving the answer (and possibly getting a conflict)
// set the message div about the answer.
// On success this will be "" on error it will be the 
// conflicting answer


<% if @old_answer %>
  $("#answer_notice_<%=@question.id%>").html("<%= escape_javascript(render partial: '/phases/answer', locals: { question: @question, answer: @old_answer}) %>"); 
<% else %>
  $("#answer_notice_<%=@question.id%>").html(""); 
<% end %>

// have to update the lock_version on success or failure
// so that the next save can work. If you don't do
// this it will fail forever.

$("#answer_lock_version-<%=@question.id%>").val(<%= @lock_version %>);