-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathapp.js
41 lines (33 loc) · 1.16 KB
/
app.js
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
(function () {
var $list = $('.list'),
itemCount = 0;
// Add x dummy items to the list
function addItems(x) {
for (var i = 0; i < x; i++) {
itemCount++;
$list.prepend('<li class="topcoat-list__item">Item ' + itemCount + '</li>');
}
}
$('.scrollable').pullToRefresh({
callback: function () {
var deferred = $.Deferred();
setTimeout(function () {
// Simulate a refresh: add 3 items to the list
addItems(3);
deferred.resolve();
}, 2000);
return deferred.promise();
}
});
// Example of a typical use of pull-to-refresh where an ajax call is made to get the latest items
// $('.scrollable').pullToRefresh({
// callback: function () {
// var promise = $.ajax({url: "http://myserver.com/myendpoint", dataType: "json", type: "GET"}).done(function (data) {
// // Add new items to the list
// });
// return promise;
// }
// });
// Populate the list with 20 items at startup
addItems(20);
}());