added function showAlert

This commit is contained in:
Sergey Yarkov 2019-10-20 00:01:40 +03:00
parent b8fa45aee8
commit f93c5ef9df
3 changed files with 18 additions and 3 deletions

View File

@ -11,6 +11,13 @@ form button {
margin-top: 20px; margin-top: 20px;
margin-bottom: 0; margin-bottom: 0;
} }
.alert {
padding: 20px;
}
.alert-wrap {
position: fixed;
right: 30px;
}
.modal { .modal {
max-height: 460px; max-height: 460px;
} }

View File

@ -11,6 +11,7 @@
</head> </head>
<body> <body>
<div class="alert-wrap"></div>
<div class="modal-mask"> <div class="modal-mask">
<div class="modal"> <div class="modal">
<div class="modal-head"> <div class="modal-head">
@ -26,9 +27,7 @@
<th class="align-right">Job</th> <th class="align-right">Job</th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody></tbody>
</tbody>
</table> </table>
</div> </div>
<div class="modal-footer"> <div class="modal-footer">

View File

@ -20,6 +20,14 @@ document.addEventListener('DOMContentLoaded', () => {
} }
} }
const showAlert = function() {
const $alert = document.querySelector('.alert-wrap');
$alert.innerHTML += '<p class="alert alert-success">Person has been successfully added!</p>';
setTimeout(() => {
$alert.querySelector('p').remove();
}, 2000);
}
$form.addEventListener('submit', (e) => { $form.addEventListener('submit', (e) => {
e.preventDefault(); e.preventDefault();
const _this = e.target, const _this = e.target,
@ -29,6 +37,7 @@ document.addEventListener('DOMContentLoaded', () => {
job = _this.job.value; job = _this.job.value;
new Person(firstName, surName, age, job).addPerson(); new Person(firstName, surName, age, job).addPerson();
showAlert();
}); });
const showPersons = function () { const showPersons = function () {