-
Notifications
You must be signed in to change notification settings - Fork 5
/
03-form.html
83 lines (71 loc) · 3.31 KB
/
03-form.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<!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 href="#page-new-book" id="btn-compose" data-icon="plus" data-iconpos="right" data-inline="true" data-role="button" data-rel="dialog" data-transition="fade" 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>
<div data-role="page" data-theme="b" id="page-new-book">
<div data-role="header" data-theme="b">
<h1>Add a New Book</h1>
</div>
<div data-role="content">
<form>
<label for="title-field">Title</label>
<textarea id="title-field"></textarea>
<label for="author-field">Author</label>
<textarea id="author-field"></textarea>
</form>
<a href="#page-books-list" data-role="button" data-theme="c" data-inline="true">Cancel</a>
<button id="create-button" data-inline="true">Create</button>
</div>
</div>
</body>
</html>