HTML and CSS Reference
In-Depth Information
Finally, the success callback is invoked with the newly saved object:
With the save method implemented, we can alter the save task event listener in tasks-con-
troller.js to utilize the method:
$(taskPage).find('#saveTask').click(function(evt) {
if ($(taskPage).find('form').valid()) {
var task = $('form').toObject();'task', task,
function(savedTask) {
$('#taskRow').tmpl( savedTask).appendTo( $(taskPage).find( '#tblTasks tbody'));
}, errorLogger);
Notice that we only update the table in the successCallback. This ensures that we do not
update the screen unless the actual save is successful.
If you now create a task, you should see the following in the Chrome resources:
The next method we will implement is findAll . Before adding this, we will provide a helper
for obtaining the de-serialized object for a specified type. This will perfom the de-serializ-
ation logic for us. This can be added as a private function at the top of storageEngine.
storageEngine = function() {
var initialized = false;
var initializedObjectStores = {};
function getStorageObject(type) {
var item = localStorage.getItem(type);
var parsedItem = JSON.parse(item);
return parsedItem;
Search WWH ::

Custom Search