-
Notifications
You must be signed in to change notification settings - Fork 48
Sockets - Kate N #33
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
base: master
Are you sure you want to change the base?
Sockets - Kate N #33
Conversation
…s the request from JS to trip API, .then loops through the response data, and displays the trip names (wave 1)
TREKWhat We're Looking For
|
| <style> | ||
| .flex-container { | ||
| display: none; | ||
| flex-wrap: nowrap; |
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.
Why is this CSS in your HTML document? It should live in a separate .css file.
It looks like you do this for the rest of your styles... I am confused.
| <body> | ||
| <div id="background"> | ||
| <img src="https://i.ibb.co/RQjSQ7w/Screen-Shot-2019-05-31-at-1-28-37-PM.png" class="stretch" alt="" /> | ||
| </div> |
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.
Watch your indentation (opt+shift+f to fix this automatically in VS Code)
|
|
||
| const displayStatus = (message) => { | ||
| $('#status').html(message); | ||
| }; |
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.
This function tries to put messages in some element on the page that has ID status, but you've commented that section out in the HTML, which means statuses don't appear.
| } | ||
| } | ||
| content += "</ul>"; | ||
| reportStatus(content); |
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.
On line 15, do you mean displayStatus? reportStatus isn't defined in this file.
| <p>${trip.about}</p> | ||
| <ul> | ||
| <li><b>Continent</b>: ${trip.continent}</li> | ||
| <li><b>Category</b>: ${trip.category}</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.
I don't know that I would use a <ul> here - what you're displaying isn't quite a list.
| $("#trip-info").empty(); | ||
| const id = $(event.target).attr("id"); | ||
| console.log("loading " + id); | ||
| showTripDetails(id); |
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.
I like the organization here, that this callback is focused on handling the DOM event and figuring out what was clicked, and showTripDetails is focused on showing details for that trip.
| $(document).on("click", "#load-trips", event => { | ||
| $('.trip-details').hide(); | ||
| loadTrips(); | ||
| }); |
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.
All of these event handler registrations should be inside of $(document).ready.
| $(document).on('submit', 'form', event => { | ||
| event.preventDefault(); | ||
| console.log("running submit"); | ||
| const trip_id = $("#trip-id").text(); |
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.
This code might be easier to read if you moved some of it to the reserveTrip function.
| console.log(response); | ||
| }) | ||
| .catch(function(error) { | ||
| console.log(error); |
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.
You should do something more than just console.log here - give the user of the site some indication of what's going on.
| .then(function (response) { | ||
| response.data.forEach((trip) => { | ||
| tripList.append(`<li><a href="" class="trip-link" id="${trip.id}">${trip.name}</a></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.
You should be using arrow functions for all of these callbacks.
TREK
Congratulations! You're submitting your assignment!
Comprehension Questions
Tripin the list by it's ID field. Would it be advantageous to keep the list in order by the id field? Explain why or why not.