| 1 | <!DOCTYPE html> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-type" content="text/html; charset=utf-8"/> |
| 5 | <meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/> |
| 6 | <meta name="apple-mobile-web-app-capable" content="yes"/> |
| 7 | <title>EdgeToEdgeStoreList - Auto Load</title> |
| 8 | |
| 9 | <script type="text/javascript" src="../deviceTheme.js" data-dojo-config="mblThemeFiles: ['base']"></script> |
| 10 | <script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true"></script> |
| 11 | |
| 12 | <script type="text/javascript"> |
| 13 | require([ |
| 14 | "dojo/_base/connect", |
| 15 | "dojo/_base/window", |
| 16 | "dojo/store/Cache", |
| 17 | "dojo/store/JsonRest", |
| 18 | "dojo/store/Memory", |
| 19 | "dojo/store/Observable", |
| 20 | "dojo/ready", |
| 21 | "dijit/registry", |
| 22 | "dojox/mobile/parser", |
| 23 | "dojox/mobile", |
| 24 | "dojox/mobile/compat", |
| 25 | "dojox/mobile/EdgeToEdgeStoreList" |
| 26 | ], function(connect, win, Cache, JsonRest, Memory, Observable, ready, registry){ |
| 27 | //var url = "data/fruits.json"; |
| 28 | var url = "data/fake_service.php"; |
| 29 | var memoryStore = new Memory({idProperty:"label"}); |
| 30 | var restStore = new JsonRest({idProperty:"label", target: url}); |
| 31 | store = new Cache(restStore, memoryStore); |
| 32 | |
| 33 | var start = 1, |
| 34 | count = 5, |
| 35 | list = null; |
| 36 | function loadMore(){ |
| 37 | setTimeout(function(){ // to simulate network latency |
| 38 | list.setQuery({start:start, count:count}); |
| 39 | start += count; |
| 40 | }, 1000); |
| 41 | }; |
| 42 | |
| 43 | ready(function(){ |
| 44 | list = registry.byId("list"); |
| 45 | list.setStore(store, {start:start, count:count}); |
| 46 | start += count; |
| 47 | connect.connect(win.global, "onscroll", null, function(e){ |
| 48 | var h = win.global.innerHeight||win.doc.documentElement.clientHeight||win.doc.documentElement.offsetHeight; |
| 49 | if(win.body().scrollTop + h === win.body().offsetHeight){ |
| 50 | loadMore(); |
| 51 | } |
| 52 | }) |
| 53 | }); |
| 54 | }); |
| 55 | </script> |
| 56 | </head> |
| 57 | <body style="visibility:hidden;"> |
| 58 | <div data-dojo-type="dojox.mobile.View"> |
| 59 | <h1 data-dojo-type="dojox.mobile.Heading" id="head1">EdgeToEdgeStoreList</h1> |
| 60 | <ul data-dojo-type="dojox.mobile.EdgeToEdgeStoreList" id="list" data-dojo-props='append:true'></ul> |
| 61 | </div> |
| 62 | </body> |
| 63 | </html> |