diff --git a/app/assets/javascripts/summary-edit.js b/app/assets/javascripts/summary-edit.js index c25153b..4f94d31 100644 --- a/app/assets/javascripts/summary-edit.js +++ b/app/assets/javascripts/summary-edit.js @@ -45,10 +45,14 @@ var editClickHandler = function(e) { } }); } + else if (thisEd.find('textarea:not(.code-answer)')) { + existingValue = thisEd.find('textarea:not(.code-answer)').val(); + thisEd.find('.chars.hidden').removeClass('hidden'); + } $('.button-edit, .submit-button').addClass('disabled-button'); thisEd.addClass('editable'); - thisEd.find('.text-answer:not(.code-answer)').replaceWith(''); + // thisEd.find('.text-answer:not(.code-answer)').replaceWith(''); thisEd.find('.answer-block, .code-answer').prop('disabled', false); thisEd.find('textarea').setTextAreaHeight(height); thisEd.find('textarea.answer-block').focus(); @@ -75,10 +79,14 @@ var cancelClickHandler = function(e) { thisEd.find('input[value="'+value+'"]').prop('checked', true); }); } + else if (thisEd.find('textarea:not(.code-answer)')) { + thisEd.find('textarea:not(.code-answer)').val(existingValue); + thisEd.find('.chars').addClass('hidden'); + } $('.success, .error').remove(); $('.button-edit, .submit-button').removeClass('disabled-button'); thisEd.removeClass('editable'); - thisEd.find('textarea:not(.code-answer)').replaceWith('

' + $.trim(thisEd.data('answer')) + '

'); + // thisEd.find('textarea:not(.code-answer)').replaceWith('

' + $.trim(thisEd.data('answer')) + '

'); thisEd.find('.answer-block, .code-answer').prop('disabled', true); thisEd.find('.button-edit').show(); thisEd.find('.button-save, .button-cancel').hide(); diff --git a/app/views/candidate/_text.html.erb b/app/views/candidate/_text.html.erb index d910317..1c6011c 100644 --- a/app/views/candidate/_text.html.erb +++ b/app/views/candidate/_text.html.erb @@ -1,6 +1,8 @@ +<% hidden = params[:action] == 'summary' ? 'hidden' : '' %> + -
Characters remaining:
+ <%= render partial: "candidate/answer_errors", locals: {question: question, answer: @answer} %>