Skip to content

Luxi Lindsey - Trek - Octos#17

Open
Lindseyls wants to merge 12 commits into
Ada-C9:masterfrom
Lindseyls:master
Open

Luxi Lindsey - Trek - Octos#17
Lindseyls wants to merge 12 commits into
Ada-C9:masterfrom
Lindseyls:master

Conversation

@Lindseyls

Copy link
Copy Markdown

TREK

Congratulations! You're submitting your assignment!

Comprehension Questions

Question Answer
What does it mean for code to be asynchronous? For code to be asynchronous means you can do many things at once with the code. For example, with AJAX, you can still interact with a webpage while waiting for a response/request. Also, the code will be executed some point in the future and is in response to some external event.
Describe a piece of your code that executes asynchronously. How did this affect the way you structured it? A piece of my code that executes asynchronously would be the axios.get(URL) and axios.post(URL). Both are interacting with an external API to render information that will be on our web app.
What kind of errors might the API give you? How did you choose to handle them? The API will give me errors if the list of trips do not load and also if the inputs are empty for the reservation form.
Do you have any recommendations on how we could improve this project for the next cohort? Learning JS and using jQuery in this project was particularly difficult for me. I had to take a lot of extra time to go through our lectures and external resources to figure out the basics of this project. I know time is always limited for learning new languages, I just wished we had more examples perhaps in class to go over together. Also, If felt that the form example that we used for pets was not explained very clearly to us.

@kariabancroft

Copy link
Copy Markdown

TREK

What We're Looking For

Feature Feedback
Core Requirements
Git hygiene Yes
Comprehension questions Yes - thanks for the note about the form. We'll be adjusting this in the future.
Functionality
Click a button to list trips Yes
Click a trip to see trip details Yes
Fill out a form to reserve a spot Yes
Errors are reported to the user Yes
Styling Yes
Under the Hood
Trip data is retrieved using from the API Yes
JavaScript is well-organized and easy to read As noted - some of the event handler functionality is tied directly to the objects rather than the DOM which can create additional complexity.
HTML is semantic Yes
Overall Overall you were able to leverage jQuery's functionality to accomplish the major requirements of this assignment. I think you could probably use a bit more practice putting data in the DOM to use within asynchronous event handler functions, as opposed to passing data directly into event handlers.

Comment thread trek.js

axios.get(URL)

.then((response) => {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread trek.js
trekDetail.html('<h4>Trip Details</h4>')

for (let data of dataField) {
let html = `<li><strong>${data}:</strong> ${response.data[data.toLowerCase()]}</li>`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really like the way you're dynamically creating the DOM elements rather than hard-coding each individual field's data

Comment thread trek.js
formTag += `<div><label for="email">Email</label>
<input type="text" name="email" /></div>`,
formTag += `<div>
<h5>Trip ID: ${id}</h5></div>`

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd love to see how you might accomplish this without explicitly putting the ID in a displayed form field.

Comment thread trek.js

$('#reserv-form').submit((event) => {
event.preventDefault();
reserveTrip(trip.id)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

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