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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.