问卷答题报网络异常

This commit is contained in:
cxt 2016-10-15 19:34:58 +08:00
parent a5375fc668
commit 750a9c9d38
1 changed files with 41 additions and 36 deletions

View File

@ -206,6 +206,8 @@
function onblur_<%= pq.id %>(obj) function onblur_<%= pq.id %>(obj)
{ {
$(window).unbind('beforeunload'); $(window).unbind('beforeunload');
var val = $(obj).val().trim();
if(val != "") {
$.ajax({ $.ajax({
type: "post", type: "post",
url: "<%= commit_answer_poll_path(@poll) %>", url: "<%= commit_answer_poll_path(@poll) %>",
@ -223,7 +225,7 @@
alert("网络异常,答题失败,请确认网络正常连接后再答题。"); alert("网络异常,答题失败,请确认网络正常连接后再答题。");
} }
}); });
}
} }
</script> </script>
<input class="fillInput" placeholder="在此填入答案" type="text" value="<%= get_anwser_vote_text(pq.id,User.current.id).html_safe %>" onblur="onblur_<%= pq.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %>> <input class="fillInput" placeholder="在此填入答案" type="text" value="<%= get_anwser_vote_text(pq.id,User.current.id).html_safe %>" onblur="onblur_<%= pq.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %>>
@ -253,6 +255,8 @@
function onblur_<%= pa.id %>(obj) function onblur_<%= pa.id %>(obj)
{ {
$(window).unbind('beforeunload'); $(window).unbind('beforeunload');
var val = $(obj).val().trim();
if(val != "") {
$.ajax({ $.ajax({
type: "post", type: "post",
url: "<%= commit_answer_poll_path(@poll) %>", url: "<%= commit_answer_poll_path(@poll) %>",
@ -272,6 +276,7 @@
} }
}); });
} }
}
</script> </script>
<p class="mb10"><%= i + 1 %>.<%= pa.answer_text%></p> <p class="mb10"><%= i + 1 %>.<%= pa.answer_text%></p>
<input class="questionnaire-input" placeholder="在此填入答案" style="width: 93%" type="text" value="<%= get_anwser_vote_text(pq.id,User.current.id,pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %>> <input class="questionnaire-input" placeholder="在此填入答案" style="width: 93%" type="text" value="<%= get_anwser_vote_text(pq.id,User.current.id,pa.id).html_safe %>" onblur="onblur_<%= pa.id %>(this);" <%= @can_edit_poll?"":"disabled=disabled" %>>