fixes #37 - textarea summary edit

again, and not the last
This commit is contained in:
Mark Moser 2016-08-05 09:52:11 -05:00
parent 8640effbfc
commit 3c3b7f5304
2 changed files with 13 additions and 3 deletions

View File

@ -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('<textarea class="answer-block">' + $.trim(thisEd.data('answer')) + '</textarea>');
// thisEd.find('.text-answer:not(.code-answer)').replaceWith('<textarea class="answer-block">' + $.trim(thisEd.data('answer')) + '</textarea>');
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('<p class="text-answer answer-container">' + $.trim(thisEd.data('answer')) + '</p>');
// thisEd.find('textarea:not(.code-answer)').replaceWith('<p class="text-answer answer-container">' + $.trim(thisEd.data('answer')) + '</p>');
thisEd.find('.answer-block, .code-answer').prop('disabled', true);
thisEd.find('.button-edit').show();
thisEd.find('.button-save, .button-cancel').hide();

View File

@ -1,6 +1,8 @@
<% hidden = params[:action] == 'summary' ? 'hidden' : '' %>
<label for="answer_text">Enter answer here</label>
<textarea id="answer_text" name="answer[text]" rows="10"><%= question.answer %></textarea>
<div class="chars">Characters remaining: <span></span></div>
<div class="chars <%= hidden %>">Characters remaining: <span></span></div>
<%= render partial: "candidate/answer_errors", locals: {question: question, answer: @answer} %>