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