HTML and CSS Reference
In-Depth Information
app.controller.favorites = function(){
var _listScroll = null;
this.init = function(){}
this.init();
}
The
_listScroll
instance variable will hold the iScroll object for the favorites
scrolling.
Listing Favorites
The first action/event that you will need to create is the
list
action. This will list
all of the favorites for the user.
Begin by creating a new action within the favorites controller called
list
.
var app = app || {};
app.controller = app.controller || {};
app.controller.favorites = function(){
...
this.list = function(){
}
...
}
The next thing that you will need to do is to grab the favorites from
localStorage
. As you saw in the bootstrap file, you created an empty favorites
localStorage
property with an empty array. This will allow you to get the
application's favorites without having to check whether the property exists, and
then create it throughout your code. It might be a good idea to create a
localStorage
utility to store your data; this won't be covered in this topic, as
you'll only be storing and retrieving
localStorage
properties in three places in
the application.
var app = app || {};
app.controller = app.controller || {};
app.controller.favorites = function(){