Skip to content

Commit

Permalink
Заменил innerHTML на .remove() при удалении страницы
Browse files Browse the repository at this point in the history
  • Loading branch information
YarikMix committed Feb 29, 2024
1 parent ae052c7 commit d82c52c
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 11 deletions.
2 changes: 1 addition & 1 deletion public/build/login.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/build/register.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions public/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const profilePage = {
}

const loginPage = {
id: "login-page",
href: "/login",
form: {
id: "login-form",
Expand Down Expand Up @@ -91,6 +92,7 @@ const loginPage = {

const registerPage = {
href: "/register",
id: "register-page",
form: {
id: "register-form",
inputs: {
Expand Down
4 changes: 2 additions & 2 deletions public/src/pages/login/login.hbs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div class="login-form-wrapper">
<form class="login-form" id="{{id}}">
<div class="login-form-wrapper" id="{{id}}">
<form class="login-form" id="login-form">
<h2 class="login-title">Форма входа</h2>
</form>
</div>
8 changes: 6 additions & 2 deletions public/src/pages/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ export default class LoginPage {
return document.getElementById(this.#config.form.id)
}

get self () {
return document.getElementById(this.#config.id)
}

validateData = () => {
const validateLogin = this.#validateLogin()
const validatePassword = this.#validatePassword()
Expand Down Expand Up @@ -102,15 +106,15 @@ export default class LoginPage {
this.#submitBtn.remove();
this.#passwordInput.remove();
this.#loginInput.remove();
this.#parent.innerHTML = '';
this.self.remove()
}

render() {
console.log("loginPage render")

this.#parent.insertAdjacentHTML(
'beforeend',
window.Handlebars.templates['login.hbs'](this.#config.form)
window.Handlebars.templates['login.hbs'](this.#config)
);

this.#loginInput = new Input(this.form, this.#config.form.inputs.login);
Expand Down
2 changes: 1 addition & 1 deletion public/src/pages/main/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default class Main {

remove(){
console.log("Main remove")
this.#parent.innerHTML = '';
this.self.remove()
}

render() {
Expand Down
2 changes: 1 addition & 1 deletion public/src/pages/notFound/not-found.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export default class NotFoundPage {
}

remove() {
this.#parent.innerHTML = '';
this.self.remove()
}

handleButtonClick = () => {
Expand Down
2 changes: 1 addition & 1 deletion public/src/pages/profile/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export default class ProfilePage {
}

remove(){
this.#parent.innerHTML = '';
this.self.remove()
}

handleLogout() {
Expand Down
2 changes: 1 addition & 1 deletion public/src/pages/register/register.hbs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div class="register-form-wrapper">
<div class="register-form-wrapper" id="register-page">
<form class="register-form" id="{{id}}">
<h2 class="register-title">Форма регистрации</h2>
</form>
Expand Down
6 changes: 5 additions & 1 deletion public/src/pages/register/register.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export default class RegisterPage {
return document.getElementById(this.#config.form.id)
}

get self () {
return document.getElementById(this.#config.id)
}

validateData = () => {
const validateLogin = this.#validateLogin()
const validatePassword = this.#validatePassword()
Expand Down Expand Up @@ -113,8 +117,8 @@ export default class RegisterPage {
}

remove(){
this.#parent.innerHTML = '';
this.#unsubscribeToEvents();
this.self.remove()
}

render() {
Expand Down

0 comments on commit d82c52c

Please sign in to comment.