-
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 - Kate Evans-Spitzer - BackTREK #40
base: master
Are you sure you want to change the base?
Conversation
BackTREKWhat We're Looking For
|
}); | ||
['name', 'continent', 'category', 'weeks', 'cost'].forEach((field) => { | ||
if (attr[field] === '') { | ||
errors[field] = "can't be blank"; |
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 suggest also adding an if statement like
if (errors[field]) {
errors[field].push('can't be blank');
} else {
errors[field] = ['can't be blank'];
}
That way you can have multiple errors for a field.
if (parseFloat(attr[field]) === NaN) { | ||
errors[field] = "must be a number"; | ||
} | ||
if (!parseFloat(attr[field]) > 0) { |
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.
No free trips?
if (object.isValid()) { | ||
object.save({}, { | ||
success: (response) => { | ||
formSuccess(type, form) |
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.
Note, for trips, this won't allow a newly created trip to show up in a displayed list. The user would have to refresh the browser to see it.
On a successful trip save, you should execute a tripList.fetch();
. That would trigger render because it's listening for an update
event.
I do however really like how you abstracted out the saveIfValid
function so it works for all your models. Nice!
$('#intro-button').on('click', (e) => { | ||
$('#intro-button').hide(200); | ||
$('#loading').show(500); | ||
tripList.fetch({ |
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 should also have an error callback, just in case the API is down to alert the user.
let field = targetElement[0].id; | ||
tripList.comparator = field; | ||
targetElement.addClass('current-sort'); | ||
tripList.sort(); |
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.
It's better stylistically to have render listening for a sort
event.
So adding tripList.on('sort', render);
BackTREK
Congratulations! You're submitting your assignment!
Comprehension Questions