Saving Data to the Server
- Cache data from the server to minimize AJAX calls
- Separate our model code, view code, and business logic code
- Maximize reuse of code
This is all well and good, but we only dealt with meaningless “item” data – our application didn’t do anything. This time we’ll begin building a simple web app to actually do something: manage simple text notes. Our app will let the user view, create, edit, and delete notes.
Check out the live demo to see it working in action. The ajax calls are programmed to fail 10% of the time to show how the UI recovers.
Since this application does so much more than the last phase, the Controller will contain much more application logic than last time. We’ll also make extensive use of the Listener Pattern for communication between parts.
The Source Code
I highly recommend downloading the source and following along. I’ll just be including specific parts of the source in each of the next steps of the tutorial, so this is your chance to see the full source in one go.
Each of the next steps will walk through a specific user action, from mouse-click to database. Since Phase 1 covered loading in data from the server, we won’t recover that. This time, we’ll look at how a note is saved, then how it’s edited, and finally how it’s deleted.