我在测试所有应用程序的表单提交时遇到了一个小问题。它是带有下划线的骨干应用程序。
我注意到在两个有循环的表单中,当按下提交按钮时,这些循环中的表单字段不会发送。我不明白为什么!
以下是提交表单的示例
<form role="form" action="" method="POST" id="voters-guide-survey">
<div class="row">
<div class="col-xs-4">
Candidate #: <strong><%= candidate.id %></strong>
</div>
<div class="col-xs-4">
Name: <strong><%= candidate.firstName %> <%= candidate.lastName %></strong>
</div>
</div>
<hr />
<div class="row">
<div class="col-xs-12">
<p>The following are 5 policy statements dealing with issues in the news. Please check the option that best reflects your point of view.</p>
</div>
</div>
<% _.each(questions, function(questionData) { %>
<div class="row">
<div class="form-group col-xs-8">
<%= questionData.question %><br />
<input type="hidden" name="question-<%= questionData.id %>" value="<%= questionData.question %>" />
<span class="error" for="survey-question-<%= questionData.id %>"></span>
</div>
</div>
<div class="row">
<div class="form-group col-xs-6">
<% _.each(questionData.options, function(option) { %>
<label class="radio-inline"><input type="radio" name="survey-question-<%= questionData.id %>" value="<%= option.name %>" required /> <%= option.name %></label><br />
<% }); %>
</div>
</div>
<% }); %>
<hr />
<div class="row">
<div class="form-group col-xs-4 col-xs-offset-4">
<input type="hidden" name="numQuestions" value="<%= questions.length %>" />
<% if (pageStatus == 'disabled') { %>
<a href="javascript:void(0);" path="questionnaire/endorsements" candidate-id="<%= candidate.id %>">Continue to Next Page »</a>
<% } else { %>
<input type="hidden" name="id" value="<%= candidate.id %>" />
<input type="hidden" name="page" value="endorsements" />
<input type="submit" name="save-questionnaire" value="Submit and Continue" />
<% } %>
</div>
</div>
</form>
循环正在迭代以下数据
{
"questions": [
{
"id": 1,
"question": "Question 1",
"options": [
{"id": 1, "name": "Strongly agree"},
{"id": 2, "name": "Somewhat agree"},
{"id": 3, "name": "Have mixed feelings"},
{"id": 4, "name": "Somewhat disagree"},
{"id": 5, "name": "Strongly disagree"},
{"id": 6, "name": "Have no opinion"},
{"id": 7, "name": "Do not wish to respond"}
],
"answer": ""
},
{
"id": 2,
"question": "Question 2",
"options": [
{"id": 1, "name": "Strongly agree"},
{"id": 2, "name": "Somewhat agree"},
{"id": 3, "name": "Have mixed feelings"},
{"id": 4, "name": "Somewhat disagree"},
{"id": 5, "name": "Strongly disagree"},
{"id": 6, "name": "Have no opinion"},
{"id": 7, "name": "Do not wish to respond"}
],
"answer": ""
},
{
"id": 3,
"question": "Question 3",
"options": [
{"id": 1, "name": "Strongly agree"},
{"id": 2, "name": "Somewhat agree"},
{"id": 3, "name": "Have mixed feelings"},
{"id": 4, "name": "Somewhat disagree"},
{"id": 5, "name": "Strongly disagree"},
{"id": 6, "name": "Have no opinion"},
{"id": 7, "name": "Do not wish to respond"}
],
"answer": ""
},
{
"id": 4,
"question": "Question 4",
"options": [
{"id": 1, "name": "Strongly agree"},
{"id": 2, "name": "Somewhat agree"},
{"id": 3, "name": "Have mixed feelings"},
{"id": 4, "name": "Somewhat disagree"},
{"id": 5, "name": "Strongly disagree"},
{"id": 6, "name": "Have no opinion"},
{"id": 7, "name": "Do not wish to respond"}
],
"answer": ""
},
{
"id": 5,
"question": "Question 5",
"options": [
{"id": 1, "name": "Strongly agree"},
{"id": 2, "name": "Somewhat agree"},
{"id": 3, "name": "Have mixed feelings"},
{"id": 4, "name": "Somewhat disagree"},
{"id": 5, "name": "Strongly disagree"},
{"id": 6, "name": "Have no opinion"},
{"id": 7, "name": "Do not wish to respond"}
],
"answer": ""
}
]
}
关于下划线模板的工作原理,我是否遗漏了什么?
当点击提交按钮时,唯一的数据是循环外的东西,所以只有隐藏的字段。
我如何使这项工作?
答案 0 :(得分:0)
抱歉愚蠢!