Objectives |
---|
Refactor Existing Front End JavaScript into OOP |
Reinforce OOP JavaScript concepts |
In your last lab we worked did some test driven development to create a JSON api using Express. For this lab we are going to take the front end JavaScript we were given and refactor it into OOP.
- Inside of the document ready, we should declare
var app = new App();
- Methods can be called on
app
from inside the document ready,
app.render();
but nothing should be defined in there!
- Define all of your variables on App:
function App(){
this.baseUrl = '/api/todos';
...
};
- Attach all of your functions to App's prototype:
App.prototype.render = function() {
this.$todosList.empty();
...
};
- Get that much set up, and then when in doubt, run the code and debug errors one by one.
- When you are finished you should be able to create, read, update and destroy todos on your app!