dojox
Version:
Dojo eXtensions, a rollup of many useful sub-projects and varying states of maturity – from very stable and robust, to alpha and experimental. See individual projects contain README files for details.
87 lines (80 loc) • 2.62 kB
HTML
<html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,minimum-scale=1,user-scalable=no"/>
<meta name="apple-mobile-web-app-capable" content="yes"/>
<title>EdgeToEdgeDataList - Auto Load</title>
<script type="text/javascript" src="../deviceTheme.js" data-dojo-config="mblThemeFiles: ['base']"></script>
<script type="text/javascript" src="../../../dojo/dojo.js" data-dojo-config="async: true, parseOnLoad: true"></script>
<script type="text/javascript">
require([
"dojo/_base/Deferred",
"dojo/dom-class",
"dojox/data/QueryReadStore",
"dojo/ready",
"dijit/registry",
"dojox/mobile/ProgressIndicator",
"dojox/mobile/parser",
"dojox/mobile",
"dojox/mobile/compat",
"dojox/mobile/ScrollableView",
"dojox/mobile/EdgeToEdgeDataList"
], function(Deferred, domClass, QueryReadStore, ready, registry, ProgressIndicator){
//var url = "data/fruits.json";
var url = "data/fake_service.php";
store = new QueryReadStore({url: url});
var start = 1,
count = 5,
prog1 = null,
list = null;
function loadMore(){
busy(true);
setTimeout(function(){ // to simulate network latency
Deferred.when(list.setQuery({start:start, count:count}), function(){
busy(false);
});
start += count;
return false;
}, 1000);
};
function busy(flag){
if(!prog1){
prog1 = new ProgressIndicator({size:30, center:false});
prog1.domNode.style.position = "absolute";
prog1.domNode.style.margin = "5px";
domClass.add(prog1.domNode, "mblProgWhite");
}
if(flag){
var head1 = registry.byId("head1");
prog1.placeAt(head1.domNode);
prog1.start();
}else{
prog1.stop();
}
}
adjustDestination = function(to, pos, dim){
var dim = this.getDim();
var h = dim.c.h; // container height
var disp = dim.d.h; // display height
if(to.y < disp - h){
loadMore();
to.y = disp - h;
}
return true;
}
ready(function(){
list = registry.byId("list");
list.setStore(store, {start:start, count:count});
start += count;
});
});
</script>
</head>
<body style="visibility:hidden;">
<div data-dojo-type="dojox.mobile.ScrollableView" data-dojo-props='adjustDestination:adjustDestination'>
<h1 data-dojo-type="dojox.mobile.Heading" id="head1" data-dojo-props='fixed:"top"'>EdgeToEdgeDataList</h1>
<ul data-dojo-type="dojox.mobile.EdgeToEdgeDataList" id="list" data-dojo-props='append:true'></ul>
</div>
</body>
</html>