Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
L
Lesson49
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Пасько Виталий
Lesson49
Commits
a51fd677
Commit
a51fd677
authored
Aug 08, 2022
by
Пасько Виталий
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- вынес скрипт в файл.
- поправил фронт.
parent
235043e7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
39 deletions
+36
-39
About.cshtml
PhoneStore/Views/Phones/About.cshtml
+21
-39
site.js
PhoneStore/wwwroot/js/site.js
+15
-0
No files found.
PhoneStore/Views/Phones/About.cshtml
View file @
a51fd677
...
@@ -8,6 +8,7 @@
...
@@ -8,6 +8,7 @@
<h2>@Model.Name</h2>
<h2>@Model.Name</h2>
<div class="card mb-3">
<div class="card mb-3">
<div class="container">
<img class="card-img-top w-50" src="~/@Model.Image" alt="Card image cap">
<img class="card-img-top w-50" src="~/@Model.Image" alt="Card image cap">
<div class="card-body">
<div class="card-body">
<h5 class="card-title">@Model.Brand.Name</h5>
<h5 class="card-title">@Model.Brand.Name</h5>
...
@@ -15,12 +16,12 @@
...
@@ -15,12 +16,12 @@
</div>
</div>
@if (User.Identity.IsAuthenticated)
@if (User.Identity.IsAuthenticated)
{
{
<form
id="feedbackForm">
<form class="mb-3"
id="feedbackForm">
<div class="form-group">
<div class="form-group">
<label for="text">Добавьте отзыв о телефоне</label>
<label for="text">Добавьте отзыв о телефоне</label>
<input type="text" class="form-control" id="text" placeholder="Минимальная длина отзыва 10 символов">
<input type="text" class="form-control" id="text" placeholder="Минимальная длина отзыва 10 символов">
<input type="text" hidden name="phoneId" id="@Model.Id">
<input type="text" hidden name="phoneId" id="@Model.Id">
<button
type="submit">Отправить</button>
<button class="my-3"
type="submit">Отправить</button>
</div>
</div>
</form>
</form>
}
}
...
@@ -28,6 +29,7 @@
...
@@ -28,6 +29,7 @@
{
{
<a asp-action="Login" asp-controller="Account">Авторизируйтесь для добавления отзыва</a>
<a asp-action="Login" asp-controller="Account">Авторизируйтесь для добавления отзыва</a>
}
}
</div>
</div>
</div>
<div id="feedbacks">
<div id="feedbacks">
@foreach (var feedBack in Model.Feedbacks)
@foreach (var feedBack in Model.Feedbacks)
...
@@ -35,23 +37,3 @@
...
@@ -35,23 +37,3 @@
await Html.RenderPartialAsync("PartialViews/FeedbackPartialView", feedBack);
await Html.RenderPartialAsync("PartialViews/FeedbackPartialView", feedBack);
}
}
</div>
</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>
}
PhoneStore/wwwroot/js/site.js
View file @
a51fd677
...
@@ -9,3 +9,18 @@
...
@@ -9,3 +9,18 @@
.
load
(
`https://localhost:5001/Account/SearchAccounts?searchTerm=
${
searchTerm
}
`
);
.
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment