Project

General

Profile

« Previous | Next » 

Revision 5667

"remember" selected/opened nodes when active domain is filtered on click. also using separate cookies for each tree so that it can remember it's state on page reload.

View differences:

index.jsp
62 62
	// TODO: remember the selected value for this when filtering by active domain
63 63
	var selectedNode = $("#" + divId).jstree("get_selected", $("#" + divId));
64 64
	var selectedNodeId = $(selectedNode).attr("id");
65
	//alert(divId + " selected node: " + selectedNodeId);
65
	//alert(divId + " selected node: " + selectedNode);
66 66
	
67 67
	// load the tree for the given div, passing in the other filtered values
68 68
	$("#" + divId).load(
......
102 102
						},
103 103
						//"core" : { "initially_open" : [ selectedNodeId ] },
104 104
						"search" : { "case_insensitive" : true },
105
						"cookies" : { 
106
								"save_opened" : "jstree_open_" + divId,
107
								"save_selected" : "jstree_select_" + divId,
108
						},
105 109
						"plugins" : [ 
106 110
							"themes", 
107 111
							"html_data", 
......
135 139

  
136 140
			// TODO: make this work
137 141
			// open to the node
138
			$("#" + divId).jstree("open_node", $(selectedNode));
139
			// select the original node 
140
			$("#" + divId).jstree("select_node", $(selectedNode));
142
			var nodePath = $("#" + divId).jstree("get_path", $(selectedNode));
143
			//alert("nodePath=" + nodePath);
144
			if (nodePath) {
145
				for (var index = 0; index < nodePath.length; index++) {
146
					$("#" + divId).jstree("open_node", $("#" + nodePath[index]));
147
					//$("#" + divId).jstree("select_node", $("#" + nodePath[index]));
148
				}
149
				// select the original node
150
				$("#" + divId).jstree("select_node", $(selectedNode), false);
151
				$("#" + divId).jstree("refresh", $(selectedNode));
152
				// TODO: scroll to selected node. 
153
				// This is supposed to be part of jsTree 1.0-rc2 but appears to be broken
154
			}
155
			
141 156
		});
142 157
}
143 158
/**

Also available in: Unified diff