-
Notifications
You must be signed in to change notification settings - Fork 43
Pipes - angela - ada-trader #26
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
base: master
Are you sure you want to change the base?
Conversation
…e view is not working.
Ada TraderWhat We're Looking For
|
| ]; | ||
|
|
||
| quoteData.forEach(function(quote) { | ||
| $('#dropdown').append(`<option>${quote.symbol}</option>`) |
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.
This code should really be within the $(document).ready(...) callback function.
The reason for that is because we're using jQuery to find the select tag on the page with ID dropdown, and then manipulating it by appending option tags inside of it. Both of these things are only guaranteed to work properly if we wait until the entire page has been loaded -- which is what the $(document).ready(...) is for.
We can see the problem manifest if we change index.html to have the script tag for app.bundle.js inside of the head tag after the meta tags, instead of at the bottom of the body tag. By moving the JS code to the top of our HTML file, the browser will load it and run the JS code in app.js first, before, loading the actual HTML content of the page.
In that case the drop down selection does not have any options added to it, because when this line of code runs jQuery cannot find the select tag with ID dropdown (because it hasn't been loaded yet from the HTML file).
| quoteList: quotes, | ||
| }); | ||
|
|
||
| const order = new Order({ |
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 doesn't look like this instance of Order is being used anywhere, so we could probably remove it?
| this.listenTo(this.model, 'update', this.render) | ||
|
|
||
| this.listenTo(this.bus, 'newOrder', this.addOrder); | ||
| this.listenTo(this.bus, 'newOrder', this.render); |
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.
In general it's totally okay to have multiple callbacks for a single event (this is especially useful when the callbacks are doing completely unrelated stuff), however in this case it's not necessary.
What will happen hear is that this.addOrder() will be called first when the newOrder event is triggered. When that method runs it calls this.model.add(), which puts the new order into the OrderList collection... which itself triggers the update event on the collection.
And we already have a listener for the update event which runs this.render(), so we're effectively calling this.render() twice. Once as a result of update and then again as a result of newOrder.
Ada Trader
Congratulations! You're submitting your assignment!
Comprehension Questions
Form error handling is not completely set up to appear in the DOM and all associated spec tests pass.