我有一个基本的反馈部分,人们可以在其中回复人们的反馈。当我单击“答复”按钮时,它应该以填充文本的方式打开模式,并将FeedbackParentId设置为已单击的反馈。但是,它始终设置为第一个反馈。
这是循环,我只在页面上显示所有反馈。
payment: {
screen: paymentdrawerstack,
navigationOptions: ({ navigation }) => {
const name = getActiveRoute(navigation.state) === 'cards' ? 'cards' : 'money';
return {
tabBarIcon: ({ tintColor }) => <Icon name={name} color={tintColor} size={20} />,
}
},
},
这是部分注释本身。为什么模态总是会得到第一个ID?
@foreach (var comment in Model.Feedback.OrderByDescending(x => x.CreatedOn))
{
<partial name="_CommentSectionPartial" model="comment" />
}
我试图像这样通过JS设置值,但不起作用。
@model FeedbackViewModel
<div class="comment-list" id="@Model.Id">
<div class="single-comment justify-content-between d-flex">
<div class="user justify-content-between d-flex">
<div class="thumb">
<img src="~/images/blog/c3.jpg" alt="">
</div>
<div class="desc">
<h5>
<a href="#">@Model.Name</a>
</h5>
<p class="date">@Model.CreatedOn.Value.ToLongDateString()</p>
<p class="comment">
@Model.Comment
</p>
</div>
</div>
<div class="reply-btn">
<div class="modal fade" id="replyModal" tabindex="-1" role="dialog" aria-labelledby="replyModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="replyModalLabel">Submit Feedback for @Model.Name</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<form id="send-reply-form" asp-action="AddReply" asp-controller="Business" asp-area="Business">
<input type="hidden" name="feedbackparentId" value="@Model.Id" />
<input type="hidden" name="businessid" value="@Model.Business.Id" />
@Html.AntiForgeryToken()
<div class="form-group form-inline">
<div class="form-group col-lg-6 col-md-6 name">
<input type="text" name="authorName" class="form-control col-form-label" id="name" placeholder="Enter Name" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter Name'">
</div>
<div class="form-group col-lg-6 col-md-6 email">
<input type="email" name="email" class="form-control" id="email" placeholder="Enter email address" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Enter email address'">
</div>
</div>
<div class="form-group">
<textarea class="form-control mb-10" rows="5" name="comment" placeholder="Message" onfocus="this.placeholder = ''" onblur="this.placeholder = 'Message'"
required=""></textarea>
</div>
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="submit" class="btn btn-primary">Send Feedback</button>
</form>
</div>
</div>
</div>
</div>
<button id="reply-button" type="button" class="btn btn-primary float-right" data-toggle="modal" data-target="#replyModal">Reply</button>
</div>
</div>
</div>
答案 0 :(得分:0)
我已经用这段代码修复了它:
$(document).on("click", "#reply-button", function () {
var feedbackId = $(this).data('id');
$(".modal-body #feedbackparentId").val(feedbackId);
console.log(feedbackId);
});