Summary live coder issues resolved

This commit is contained in:
Derek Montgomery 2016-07-29 14:51:20 -05:00
parent 56d212baa7
commit 9b0bd79ce5
2 changed files with 15 additions and 14 deletions

View File

@ -92,7 +92,17 @@ var saveClickHandler = function(e) {
var data =[]; var data =[];
var executeQuery; var executeQuery;
var questionId = thisEd.find('.button-edit').attr('data-questionid'); var questionId = thisEd.find('.button-edit').attr('data-questionid');
if(thisEd.find('input').attr('type')=='radio') {
if (thisEd.find('textarea.code-answer')) {
var htmlAnswer = $(thisEd.find('textarea.code-html')[0]).val();
var cssAnswer = $(thisEd.find('textarea.code-css')[0]).val();
var jsAnswer = $(thisEd.find('textarea.code-js')[0]).val();
data = {
'html': htmlAnswer,
'css': cssAnswer,
'js': jsAnswer
}
} else if(thisEd.find('input').attr('type')=='radio') {
$(thisEd.find('input')).each(function() { $(thisEd.find('input')).each(function() {
if($(this).prop('checked')==true) { if($(this).prop('checked')==true) {
data = $(this).val(); data = $(this).val();
@ -104,15 +114,6 @@ var saveClickHandler = function(e) {
data.push($(this).val()); data.push($(this).val());
} }
}); });
} else if (thisEd.find('textarea.code-answer')) {
var htmlAnswer = $(thisEd.find('textarea.code-html')[0]).val();
var cssAnswer = $(thisEd.find('textarea.code-css')[0]).val();
var jsAnswer = $(thisEd.find('textarea.code-js')[0]).val();
data = {
'html': htmlAnswer,
'css': cssAnswer,
'js': jsAnswer
}
} else { } else {
data = thisEd.find('textarea').val(); data = thisEd.find('textarea').val();
} }
@ -122,7 +123,7 @@ var saveClickHandler = function(e) {
thisEd.find('textarea:not(.code-answer)').replaceWith('<p class="text-answer answer-container">' + $.trim(thisEd.find('textarea').val()) + '</p>'); thisEd.find('textarea:not(.code-answer)').replaceWith('<p class="text-answer answer-container">' + $.trim(thisEd.find('textarea').val()) + '</p>');
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "assets/update_from_summary.php", url: "/summary",
data:{ id: questionId, answer: data}, data:{ id: questionId, answer: data},
success: function(data){ success: function(data){
executeQuery = true; executeQuery = true;

View File

@ -1,16 +1,16 @@
<div class="code-input"> <div class="code-input">
<label for="code-html">HTML</label> <label for="code-html">HTML</label>
<textarea data-id="code-html" name="code-html" class="code-answer"><%= @answer['html'] unless @answer.nil? %></textarea> <textarea data-id="code-html" name="code-html" class="code-answer code-html"><%= @answer['html'] unless @answer.nil? %></textarea>
</div> </div>
<div class="code-input"> <div class="code-input">
<label for="code-css">CSS</label> <label for="code-css">CSS</label>
<textarea data-id="code-css" name="code-css" class="code-answer"><%= @answer['css'] unless @answer.nil? %></textarea> <textarea data-id="code-css" name="code-css" class="code-answer code-css"><%= @answer['css'] unless @answer.nil? %></textarea>
</div> </div>
<div class="code-input"> <div class="code-input">
<label for="code-js">JS</label> <label for="code-js">JS</label>
<textarea data-id="code-js" name="code-js" class="code-answer"><%= @answer['js'] unless @answer.nil? %></textarea> <textarea data-id="code-js" name="code-js" class="code-answer code-js"><%= @answer['js'] unless @answer.nil? %></textarea>
</div> </div>
-- MOVE TO FLASH HASH -- -- MOVE TO FLASH HASH --