This lab should help you improve your javascript understanding. The goal of the lab is to get this todo single page app fully functional. However, in order to do that, you must understand the javascript code first. This will take lots of looking at the code, setting break points, and playing around with different things. DO NOT MOVE ON UNTIL YOU UNDERSTAND THE CODE!!
Look at the rails project and try to understand the state of the code. Pay close attention to app/assets/javascript/todos.js
. You should try to fully understand the code here before moving onto another step. If you ever get confused about some of the code later on in these steps, stop what you're doing and understand the code.
The application has a bug at the moment. When you create a new todo item then click the checkbox for done, there is a javascript error. What is causing the error. Debug the issue!
The save model and update model methods are not working. Add the code to actually save the data to the rails backend. Start with the save first, then move on to update. There is a little more to do for update that you need to figure out.
Add the code for deleting a todo item.
Tomorrow you will be asked to give a quick talk on javascript hoisting. Look at the hoisting section on javascript garden
- In order for the code to make sense you need to be comfortable with javascript scopeing and the use of the
this
keyword. If you do not feel comfortable yet, check out http://bonsaiden.github.io/JavaScript-Garden/#function - The application uses JS namesapcing a little differently than you've seen before. How is it different?
- What is the purpose of _this in the code? Is it different than the keyword
this
?