Adding tags as string

Currently we just treat the tags as string, so it is same as the isbn and title field.

1var Book = (function(){
2  function Book(title, isbn, tags) {
3    this.title = title;
4    this.isbn = isbn || "";
5    this.tags = tags || "";
6  }
7  return Book;
8})();

In the form of adding book, we add an input for the tags.

1<li><input type='text' data-mini='true' id='book-tags' placeholder='Tags (Separated by comma)'></li>

And the book entry template too.

 1<div id='templates'>
 2  <li class='book-entry'>
 3    <a class='amazon-link' href='#'>
 4      <h1 class='book-title'></h1>
 5      <p class='isbn'></p>
 6      <p class='tags'></p>
 7      <p class='ui-li-count'><a href='#' class='delete-btn' data-isbn=''>X Remove</a></p>
 8    </a>
 9  </li>
10</div>

In order to search by tags, we add data-filter='true' to the books list ul.

And we add tags to everywhere with title and isbn, including the view and the addBook function.

1data.addBook = function(title, isbn, tags) {
2  this.books.push(new Book(title, isbn, tags));
3  this.saveToLocal();
4};

What’s next? We’re going to take a look at “Refractoring the LocalStorage module”.

overlaied image when clicked on thumbnail

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