-
Notifications
You must be signed in to change notification settings - Fork 5
/
02-read.html
67 lines (56 loc) · 2.53 KB
/
02-read.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<!DOCTYPE html>
<html>
<head>
<title>Apigee Training App</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.1/jquery.mobile-1.1.1.min.js"></script>
<script src="https://apigee.com/usergrid/sdk/usergrid.0.10.5.js"></script>
<script type="text/javascript">
var apigee = new Usergrid.Client({
orgName:'YOUR APIGEE.COM USERNAME',
appName:'sandbox'
});
// A Collection object that will be used to hold the list of books locally
var my_books = new Usergrid.Collection( { "client":apigee, "type":"books" } );
// Actual network call
my_books.fetch(
// Success Callback
function () {
$('#books-list').empty();
while ( my_books.hasNextEntity() ) {
var current_book = my_books.getNextEntity();
// Output the book on the page
$('#books-list').append('<li><h3>'+current_book.get('title')+'</h3><p>'+current_book.get('author')+'</p></li>');
}
// Re-apply jQuery Mobile styles
$('#books-list').listview('refresh');
},
// Failure Callback
function () { alert("read failed"); }
);
</script>
</head>
<body>
<div data-role="page" data-theme="c" id="page-books-list">
<div data-role="header" data-theme="b">
<h1>My Books</h1>
<a id="btn-compose" data-icon="plus" data-iconpos="right" data-inline="true" data-role="button" class="ui-btn-right">Add</a>
</div>
<div data-role="content">
<ul id="books-list" data-role="listview" data-inset="false" >
<li>
<h3>First Title</h3>
<p>First author</p>
</li>
<li>
<h3>Second Title</h3>
<p>Second author</p>
</li>
</ul>
</div>
</div>
</body>
</html>