-
Notifications
You must be signed in to change notification settings - Fork 44
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
Pipes - Irene - BackTREK #22
base: master
Are you sure you want to change the base?
Conversation
BackTREKWhat We're Looking For
|
tripList.fetch(); | ||
|
||
// Listen and register. Once an update has been heard, render all the collection into the template | ||
tripList.on('update', renderList); |
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.
Minor note: It's theoretically possible (1 in a trillion chance) that the fetch
could finish and return before this line being executed. In which case renderList
would not be executed. It's more proper to establish your listeners and then run fetch
.
<script src="app.bundle.js" type="text/javascript"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/foundation/6.4.3/js/foundation.js"></script> |
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.
By adding foundation here you're getting an error because jQuery isn't defined in global scope. to get rid of it you'd need to link in jQuery via a script tag, or use the foundation-sites npm package.
const Reservation = Backbone.Model.extend({ | ||
baseURL: 'https://ada-backtrek-api.herokuapp.com/trips', | ||
url: function() { | ||
return this.baseURL + '/' + this.attributes.tripId + '/' + 'reservations'; |
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 could also specify a urlRoot
function.
urlRoot() {
return `${this.baseURL}/${this.get('tripId')/+reservations`;
},
Note the string interpolation.
}, | ||
|
||
validate: function(attributes) { | ||
const errors = {}; |
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.
Good, but I'd also suggest making sure the email has an @
in it.
if (!attributes.category) { | ||
errors['category'] = ['Category cannot be blank!']; | ||
} | ||
if (!attributes.weeks) { |
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 would also check for a numeric value of weeks and cost and make sure they are non-negative.
|
||
reservation[field] = value; | ||
|
||
inputElement.val(''); |
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 suggest only clearing the input values on a successful save. Otherwise you're clearing the tripId and there's no way for a user to enter that.
BackTREK
Congratulations! You're submitting your assignment!
Comprehension Questions