How Do I Refresh a Dijit Tree?
Dijit is the name of a component that is part of the Dojo Toolkit, a collection of JavaScript tools for Web pages. By using Dijit, Web developers can integrate what is known as a Dijit tree, a hierarchical structure that organizes data into various categories. If you want the Web page to automatically refresh a Dijit tree, you can define a new function that will perform that action and call the function when needed.
Instructions
-
-
1
Launch Notepad, the Windows text editor, and open the file that contains the source code of your Dojo script.
-
2
Type or cut-and-paste the following code near the top of the file:
<script language="JavaScript" type="text/javascript">
dojo.extend(dijit.Tree, {
refresh: function() {
this._itemNodesMap={};
this.model.root = null {};
if(this.rootNode) { this.rootNode.destroyRecursive();}
this._load;}
});
</script>
The code creates a new function that refreshes the Dijit tree when called. -
-
3
Call the function at any point in your script by inserting the following function call:
dijit.byID('treeid').refresh();
Replace "treeid" by the actual identification code assigned to the tree. -
4
Click on "File" and select "Save."
-
1