Adding the ISBNs to tag data

 1data.addIsbnToTags = function(isbn, tagsString) {
 2  var tags = tagsString.split(/\s*,\s*/);
 3  for (var i=0, len=tags.length; i<len; i++) {
 4    var key = "tag:" + tags[i];
 5    var list = this.storage.loadList(key);
 6    list.push(isbn);
 7    this.storage.saveList(key, list);
 8  }
 9};

Call the addIsbnToTags whenever we add a book.

1data.addBook = function(title, isbn, tags) {
2  this.books.push(new Book(title, isbn, tags));
3  this.storage.saveList("books", this.books);
4  this.addTags(tags);
5};
1data.addBook = function(title, isbn, tags) {
2  this.books.push(new Book(title, isbn, tags));
3  this.storage.saveList("books", this.books);
4  this.addTags(tags);
5  this.addIsbnToTags(isbn, tags);  // Newly added
6};

What’s next? We’re going to take a look at “Getting the book list from tag”.

overlaied image when clicked on thumbnail

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