Just finished Chapter 10 and running into an error. When I hit the Submit button, my output in the console shows that the code runs through twice even though I only clicked the button once. The first console log shows the proper coffee order information, the second shows default (blank values) and then produces “Uncaught TypeError: fn is not a function.” Despite this, myTruck.printOrders(); still works and shows the pending order. Note that I’m passing in the binded createOrder function to fn so the error is not because I didn’t pass anything to the fn parameter in formHandler.
Here is a screenshot:
I couldn’t find the source of the error, so I downloaded the solution from the Big Nerd Ranch website to compare. I ran the solution code and the same thing happened. I get two logs in the console (one correct, one empty), and the “Uncaught TypeError” message.
At this point, I figured it wasn’t a typo in my code since the BNR solution produced the same error. I googled and found a solution suggesting to add “event.stopImmediatePropagation();” after “event.preventDefault();” in formHandler.js. It looks like it’s working properly with that fix.
Any idea why I’m getting the error when I don’t use stopImmediatePropagation()?
Here are screenshots of the working console output, main.js and formHandler.js files (had to use imgur because of new user upload restrictions): http://imgur.com/a/DNEh9