Skip to content

Commit

Permalink
Move clearInputs functionality to view
Browse files Browse the repository at this point in the history
  • Loading branch information
amejid committed Jul 3, 2022
1 parent 75b15d0 commit 68210f1
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const addBook = () => {
const [title, author] = bookAddView.getFormValues();
if (!title || !author) return;
model.addBook(title, author);
bookAddView.clearInputs();
bookView.render(model.state.books);
};

Expand Down
7 changes: 5 additions & 2 deletions modules/views/bookAddView.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,16 @@ class BookAddView {

#btnAddEl = document.querySelector('.btn-submit');

clearInputs() {
#clearInputs() {
this.#titleEl.value = '';
this.#authorEl.value = '';
}

getFormValues() {
return [this.#titleEl.value.trim(), this.#authorEl.value.trim()];
const info = [this.#titleEl.value.trim(), this.#authorEl.value.trim()];

this.#clearInputs();
return info;
}

addHandlerAdder(handler) {
Expand Down

0 comments on commit 68210f1

Please sign in to comment.