所以这是一个简短的解释:我有几个类别的html,我有两个下面列出的,但通常有五个。以下是注册和 lobby 。我有几个带有预先写好的响应的div,供用户点击,我还有一个添加按钮,以便他们可以添加新的响应。
每个类别的底部是addResponses.html.twig
html。它包含要单击的按钮,然后div下拉,用户输入新的响应,点击 Enter 并将其添加到其他div,基本上是一个精确的副本。
PROBLEM
:
目前,问题在于它非常适用于注册,但当我尝试将响应添加到其他类别时,例如 lobby ,它会添加{ {1}}但不添加文字。
Div
:
Html
<!-- Registration -->
<div class="row responses panel">
<div class="small-12 column" data-category="a">
<h3>Registration and Confirmation Email</h3>
</div>
<div class="small-12 column">
<div class="callout panel notes"
data-response-text="- No Time/Date on registration page"
data-response-check="^a1"
data-status-flag="1">
No Time/Date on registration page
</div>
</div>
<div class="small-12 column">
<div class="callout panel notes"
data-response-text="- No registration page"
data-response-check="^a1, ^a2, ^a3, ^a4, ^a5"
data-status-flag="1">
No registration page
</div>
</div>
<div class="small-12 column">
<div class="callout panel notes"
data-response-text="- Banner/Logo not displaying correctly"
data-response-check=""
data-status-flag="1">
Banner/Logo not displaying correctly
</div>
</div>
{% include 'QCBundle::Event/addResponses.html.twig' %}
</div>
<!-- Lobby -->
<div class="row responses panel">
<div class="small-12 columns" data-category="b">
<h3>Lobby</h3>
</div>
<div class="small-12 column">
<div class="callout panel notes"
data-response-text="- Time/Date not correct"
data-response-check="^b1"
data-status-flag="1">
Time/Date not correct
</div>
</div>
<div class="small-12 column">
<div class="callout panel notes"
data-response-text="- Time/Date not listed"
data-response-check="^b1"
data-status-flag="1">
Time/Date not listed
</div>
</div>
<div class="small-12 column">
<div class="callout panel notes"
data-response-text="- Banner/Logo not displaying correctly"
data-response-check="^b1"
data-status-flag="1">
Banner/Logo not displaying correctly
</div>
</div>
{% include 'QCBundle::Event/addResponses.html.twig' %}
</div>
:
addResponses.html.twig
<div class="small-12 column">
<div class="add-new-box">
<div class="add-new">
Add Response
</div>
<div class="add-new-text">
<input class="text-response" type="text" placeholder="Response">
</div>
</div>
</div>
:
JavaScript
答案 0 :(得分:1)
这一行:
var response= $(".text-response").val();
应该是:
var response= $(this).val();
否则,您始终从页面上的第一个.text-response
字段获取值,而不是用户正在填写的值。