Skip to content
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

Open
wants to merge 19 commits into
base: master
Choose a base branch
from

Conversation

KateMhq
Copy link

@KateMhq KateMhq commented Sep 24, 2018

No description provided.

</head>
<body>
<h1>My Favorites</h1>
<!-- <form class="search-area">
Copy link
Collaborator

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");
Copy link
Collaborator

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) {
Copy link
Collaborator

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) {
Copy link
Collaborator

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;
Copy link
Collaborator

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{
Copy link
Collaborator

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;
Copy link
Collaborator

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 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants