Current File : /home/obaba/public_html/admin/assets/plugins/dynatree/doc/sample-lazy.html |
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Dynatree - Example</title>
<script src="../jquery/jquery.js" type="text/javascript"></script>
<script src="../jquery/jquery-ui.custom.js" type="text/javascript"></script>
<script src="../jquery/jquery.cookie.js" type="text/javascript"></script>
<link href="../src/skin-vista/ui.dynatree.css" rel="stylesheet" type="text/css">
<script src="../src/jquery.dynatree.js" type="text/javascript"></script>
<!-- Start_Exclude: This block is not part of the sample code -->
<link href="prettify.css" rel="stylesheet">
<script src="prettify.js" type="text/javascript"></script>
<link href="sample.css" rel="stylesheet" type="text/css">
<script src="sample.js" type="text/javascript"></script>
<!-- End_Exclude -->
<script type="text/javascript">
$(function(){
// --- Initialize sample trees
$("#tree").dynatree({
title: "Lazy loading sample",
fx: { height: "toggle", duration: 200 },
autoFocus: false, // Set focus to first child, when expanding or lazy-loading.
// In real life we would call a URL on the server like this:
// initAjax: {
// url: "/getTopLevelNodesAsJson",
// data: { mode: "funnyMode" }
// },
// .. but here we use a local file instead:
initAjax: {
url: "sample-data3.json"
},
onActivate: function(node) {
$("#echoActive").text("" + node + " (" + node.getKeyPath()+ ")");
},
onLazyRead: function(node){
// In real life we would call something like this:
// node.appendAjax({
// url: "/getChildrenAsJson",
// data: {key: node.data.key,
// mode: "funnyMode"
// }
// });
// .. but here we use a local file instead:
node.appendAjax({
url: "sample-data2.json",
// We don't want the next line in production code:
debugLazyDelay: 750
});
}
});
$("#btnReloadActive").click(function(){
var node = $("#tree").dynatree("getActiveNode");
if( node && node.isLazy() ){
node.reloadChildren(function(node, isOk){
});
}else{
alert("Please activate a lazy node first.");
}
});
$("#btnLoadKeyPath").click(function(){
var tree = $("#tree").dynatree("getTree");
// Make sure that node #_27 is loaded, by traversing the parents.
// The callback is executed for every node as we go:
tree.loadKeyPath("/folder4/_23/_26/_27", function(node, status){
if(status == "loaded") {
// 'node' is a parent that was just traversed.
// If we call expand() here, then all nodes will be expanded
// as we go
node.expand();
}else if(status == "ok") {
// 'node' is the end node of our path.
// If we call activate() or makeVisible() here, then the
// whole branch will be exoanded now
node.activate();
}
});
});
<!-- Start_Exclude: This block is not part of the sample code -->
$("#skinCombo")
.val(0) // set state to prevent caching
.change(function(){
var href = "../src/"
+ $(this).val()
+ "/ui.dynatree.css"
+ "?reload=" + new Date().getTime();
$("#skinSheet").attr("href", href);
});
<!-- End_Exclude -->
});
</script>
</head>
<body class="example">
<h1>Example: Lazy loading</h1>
<p class="description">Using 'lazy' option to load the tree and to load the
branches.<br>
<br>
You may want to try this <a href="sample-lazy-persist.html">live example</a> of
a lazy tree that uses a simple test server.
</p>
<div>
Skin:
<select id="skinCombo" size="1">
<option value="skin">Standard ('/skin/')</option>
<option value="skin-vista">Vista ('/skin-vista/')</option>
</select>
</div>
<div id="tree"><!-- When using initAjax, it may be nice to put a throbber here, that spins until the initial content is loaded: -->
</div>
<div>Active node: <span id="echoActive">-</span></div>
<p>
<button id="btnReloadActive">Reload active node...</button>
<button id="btnLoadKeyPath">Load node by path '/folder4/_23/_26/_27'...</button>
</p>
<!-- Start_Exclude: This block is not part of the sample code -->
<hr>
<p class="sample-links no_code">
<a class="hideInsideFS" href="http://dynatree.googlecode.com">jquery.dynatree.js project home</a>
<a class="hideOutsideFS" href="#">Link to this page</a>
<a class="hideInsideFS" href="samples.html">Example Browser</a>
<a href="#" id="codeExample">View source code</a>
</p>
<pre id="sourceCode" class="prettyprint" style="display:none"></pre>
<!-- End_Exclude -->
</body>
</html>