diff options
Diffstat (limited to 'js/dojo-1.7.2/dojox/dtl/demos/demo_Tree.html')
| -rw-r--r-- | js/dojo-1.7.2/dojox/dtl/demos/demo_Tree.html | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/js/dojo-1.7.2/dojox/dtl/demos/demo_Tree.html b/js/dojo-1.7.2/dojox/dtl/demos/demo_Tree.html new file mode 100644 index 0000000..897ce8a --- /dev/null +++ b/js/dojo-1.7.2/dojox/dtl/demos/demo_Tree.html @@ -0,0 +1,48 @@ +<html> + <head> + <title>Demo to show recursion in DTL</title> + <script type="text/javascript" src="../../../dojo/dojo.js" + djConfig="isDebug: true, parseOnLoad: true"></script> + <script type="text/javascript"> + dojo.require("dijit._WidgetBase"); + dojo.require("dojox.dtl._DomTemplated"); + dojo.require("dojo.data.ItemFileReadStore"); + dojo.require("dojo.parser"); + + (function(){ + var data = {}; + + // The only way to get ItemFileReadStore to work + // synchronously (necessary for the bind_query format + // we'll be using below) at the time of this writing + // was to feed it data + dojo.xhrGet({ + url: dojo.moduleUrl("dijit.tests._data", "countries.json"), + handleAs: "json", + sync: true, + load: function(json){ + data = json; + } + }); + + dojo.declare("demo.Tree", [dijit._WidgetBase, dojox.dtl._DomTemplated], { + constructor: function(){ + this.disabled = {}; + }, + toggle: function(e){ + var dataid = dojo.attr(e.target, "dataid"); + this.disabled[dataid] = !this.disabled[dataid]; + this.render(); + }, + store: new dojo.data.ItemFileReadStore({ data: data }), + query: { type: "continent" }, + templateString: '{% load dojox.dtl.contrib.objects %}{% load dojox.dtl.contrib.data %}{% bind_query query to store as countries %}<ul dojoAttachEvent="onclick: toggle">{% for country in countries %}{% include countrychildren %}{% endfor %}</ul>', + countrychildren: '<li dataid="{{ country.getIdentity }}">{{ country.type }}: {{ country.name }}{% if country.children %}{% if disabled|key:country.getIdentity %} ↵{% else %}<ul>{% for country in country.children %}{% include countrychildren %}{% endfor %}</ul>{% endif %}{% endif %}</li>' + }); + })(); + </script> + </head> + <body> + <div dojoType="demo.Tree"></div> + </body> +</html> |
