Reseting all data

Put the button in HTML.

1<p><a data-role='button' id='reset-all-btn'>Reset All Data</a></p>

Create a reset function in data object.

1data.resetAll = function() {
2  localStorage.clear();
3  data.books = [];
4};

Bind the view and data together.

1$('#reset-all-btn').click(function(){
2  app.data.resetAll();
3  app.view.renderList();
4  app.view.renderTags();
5});

Keep in mind that you may not really want to clear all the data when your code is a library. You may want to remember what keys you have created and just remove keys from your code by using the removeItem method.

What’s next? We’re going to take a look at “Optional – Panel”.

overlaied image when clicked on thumbnail

Makzan | Mobile web app dev with phonegap | Table of Content