-
Notifications
You must be signed in to change notification settings - Fork 38
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
accidentally closed the previous pull request #29
base: master
Are you sure you want to change the base?
Conversation
</head> | ||
<body> | ||
<h1>My Favorites</h1> | ||
<!-- <form class="search-area"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Commented out code can be removed
//this is to insert search results using dom | ||
function searchResult(body) { | ||
body.Search.forEach(movie => { | ||
let searchResultContainer = document.createElement("li"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be easier to create elements using HTML string templates rather than using createElement for each item
|
||
let favorite = document.createElement("button"); | ||
favorite.innerHTML = "Add to favorites"; | ||
favorite.addEventListener("click", function(event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be better to use event delegation. Let the events bubble up and handle them in one place rather than place place event handlers on elements individually
}); | ||
} | ||
|
||
searchSubmit.addEventListener("click", function(event) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We want to listen for a submit event on the form rather than a click on submit button
.then(response => response.json()) | ||
.then(body => { | ||
if (typeof body.Search !== "undefined") { | ||
let arr=body.Search; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
there is a fair bit of code duplication here. We could instead use a loop here to perform same task 3 times
} | ||
|
||
|
||
.search-area{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would have been great to see more BEM style CSS selectors in use
|
||
|
||
.search-area{ | ||
display: grid; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love seeing grid being used :)
No description provided.