Luxi Lindsey - Trek - Octos#17
Conversation
…ted the set up with semantic HTML tags, one line of css code, and the axios to load the list of trips.
TREKWhat We're Looking For
|
|
|
||
| axios.get(URL) | ||
|
|
||
| .then((response) => { |
There was a problem hiding this comment.
It is actually preferred to put the then and catch blocks immediately after the get function call with no whitespace. It makes it a bit more clear that they are callback functions.
| trekDetail.html('<h4>Trip Details</h4>') | ||
|
|
||
| for (let data of dataField) { | ||
| let html = `<li><strong>${data}:</strong> ${response.data[data.toLowerCase()]}</li>`; |
There was a problem hiding this comment.
I really like the way you're dynamically creating the DOM elements rather than hard-coding each individual field's data
| formTag += `<div><label for="email">Email</label> | ||
| <input type="text" name="email" /></div>`, | ||
| formTag += `<div> | ||
| <h5>Trip ID: ${id}</h5></div>` |
There was a problem hiding this comment.
I'd love to see how you might accomplish this without explicitly putting the ID in a displayed form field.
|
|
||
| $('#reserv-form').submit((event) => { | ||
| event.preventDefault(); | ||
| reserveTrip(trip.id) |
There was a problem hiding this comment.
By putting all of your event handlers in functions where you have access to the data immediately, you've avoided the interesting problem of event delegation. By moving these functions into your $(document).ready you could then leverage the DOM to pull out this data, instead of having access directly to the trip's ID for instance.
TREK
Congratulations! You're submitting your assignment!
Comprehension Questions