- вынес скрипт в файл.

- поправил фронт.
parent 235043e7
......@@ -8,6 +8,7 @@
<h2>@Model.Name</h2>
<div class="card mb-3">
<div class="container">
<img class="card-img-top w-50" src="~/@Model.Image" alt="Card image cap">
<div class="card-body">
<h5 class="card-title">@Model.Brand.Name</h5>
......@@ -15,12 +16,12 @@
</div>
@if (User.Identity.IsAuthenticated)
{
<form id="feedbackForm">
<form class="mb-3" id="feedbackForm">
<div class="form-group">
<label for="text">Добавьте отзыв о телефоне</label>
<input type="text" class="form-control" id="text" placeholder="Минимальная длина отзыва 10 символов">
<input type="text" hidden name="phoneId" id="@Model.Id">
<button type="submit">Отправить</button>
<button class="my-3" type="submit">Отправить</button>
</div>
</form>
}
......@@ -28,6 +29,7 @@
{
<a asp-action="Login" asp-controller="Account">Авторизируйтесь для добавления отзыва</a>
}
</div>
</div>
<div id="feedbacks">
@foreach (var feedBack in Model.Feedbacks)
......@@ -35,23 +37,3 @@
await Html.RenderPartialAsync("PartialViews/FeedbackPartialView", feedBack);
}
</div>
@section Scripts
{
<script >
$(document).ready(function (){
$("#feedbackForm").on("submit", function (e){
e.preventDefault();
let phoneId = $("input[name=phoneId]");
let text = $("#text");
let feedback = {
text: text.val(),
phoneId: phoneId.attr('id')
};
$.post(`@Url.Action("Create", "Feedback")`, feedback, function (response){
$('#feedbacks').before(response);
})
})
})
</script>
}
......@@ -9,3 +9,18 @@
.load(`https://localhost:5001/Account/SearchAccounts?searchTerm=${searchTerm}`);
})
});
$(document).ready(function (){
$("#feedbackForm").on("submit", function (e){
e.preventDefault();
let phoneId = $("input[name=phoneId]");
let text = $("#text");
let feedback = {
text: text.val(),
phoneId: phoneId.attr('id')
};
$.post('https://localhost:5001/feedback/create', feedback, function (response){
$('#feedbacks').before(response);
});
});
});
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment