Melissa : Edges : Trek#36
Conversation
TREKWhat We're Looking For
Nicely done on this project, Melissa! I'm really happy with how the code looks-- incredibly clean, readable, logical, and practical! It's a great project submission. I have a few nuanced comments on how you approached the event delegation, but otherwise I'm really pleased with the code. Really great work! |
| reportStatus(`Successfully loaded ${response.data.length} trips`); | ||
| // sort | ||
| response.data.forEach((trip) => { | ||
| tripList.append(`<li><a href='#' class="trip_id" id=${trip.id}>${trip.name}</li>`); |
There was a problem hiding this comment.
You should probably not include the `href='#' bit, otherwise it changes the URL of the browser
also instead of setting trip.id to be the value of id, you could probably set it to an attribute like data-id instead
|
|
||
| $('body').on('click', '.trip_id', function(event){ | ||
| loadTripDetails(event.target.id); | ||
| }); |
There was a problem hiding this comment.
nice use of Event Delegation. I personally would've preferred if the selectors were more specific (instead of selecting on body you waiting until showing the #trip-list and selecting that) (or also, changing the name of the class of trip_id since that's not really accurate for what those elements are), but it works all the same!
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.