# __ .______ __ __ .______ .___________. ______ ______ .___ ___. # | | | _ \ | | | | | _ \ | | / | / __ \ | \/ | # | | | |_) | | |__| | | |_) | `---| |----` | ,----'| | | | | \ / | # | | | ___/ | __ | | ___/ | | | | | | | | | |\/| | # | | | | | | | | | | | | __ | `----.| `--' | | | | | # |__| | _| |__| |__| | _| |__| (__) \______| \______/ |__| |__| # ""$o o$"" ""$o o$" o "$""""o "o $" o""" $" "$o "$o" $o " $ o$" "$o $$$o$$$$o$$$$ $" "oooo o "" ""$$$$$$$$""o"" oo oooo" "$$$$$$oo"oo$$$o" o$$$$oo" o$$$o "o$$$$$$$ "$ $$$$$$$$$oo o$$$$$$$$$o"$" $ $$$ $$$$$$ o$$$$$$ "$$o"o $ $$$$o $$$$$$ $$$$$$$ $$$$o"o $ $$$$$ $$$$$" "$$$$$ $$$$$$ $ $o""""" """" """ """"""$" $ o$$$$$"""$$$$$"$$$$$""$$$$$ooo"o $ o"$o $$$$$$$$oo$$$$$$$$o $$"" $ oo$ "$$$$$$$$$$$$$$$$$$$$" o" o $oo o$$$"$ $$o"o $$$$$$$"" "$$$$$$$ o$$ $$$$o IPHPT BUG o$$$$" $ $$$$ o "$$$$$oo o$$$$$$ "o$$$$ $ $$$$$ o$$"" $ $$$$$o" "$$$$$$$$$$$$$ o o$$$$$o$ "" $$ $$" $ $$$" o"o$$$$$$$$$$$$ " "$$$ $ $$o o$$ "o $$ " $$$$$$$$$$$"o "$$ $ $$$ $$$ oo$ $ o""$$""$$$o " $"o$o $$$o o$$$$ o$$$"o"$oo$$$$o" o $o $$$$$oo$ $$$$o $$$$ $$$$ $$$$" $ $$$$$"" $$ o$$$ """$$$$"o" "$$$o "$$$o $$$" o """ $ $$$oo $$$$o" $$ o$$$"o" """"$ o$$$ o$" $$$ $ "$"" o$"o"$$o$$$$ "$$"o" o$$ "$oo $ " $$o $ "oo$"o$$$"o$o"$$$$o" o" $$$ ""$o $$ $$$o "o$$o$"$$"$$o$$o$$"$$o" $$$ ""o $$$ ""$$$ $$$$$$ $$$$ $" $$$$ $$ $$$$ $$$$"$$$o$ $"" $$$ $$$$ "$$$ """ $$$$ $$"" "$$ oo$" $ooo $ "$$ fancytree 插件自动选中   -  叶落山城秋

fancytree 插件自动选中

曾用到这个fancytree插件,找了好久才找到这个自动选中的源码

if ($("entityTree") != null) {
	$(function () {
		// Create
		the tree inside the <div id="tree"> element.
		$("#entityTree").fancytree({
			source: { url: "/Home/GetTreeViewData",
					 cache: true }
			, checkbox: true
			, icons: false
			, cache: true
			, lazyLoad: function (event, data) {
				var node = data.node;
				data.result = {
					url:
					"/Home/GetTreeViewData/" +
					node.key.replace(node.data.idPrefix, "")
					, data: { mode:
							 "children", parent: node.key }
					, cache: true
				};
			}
			, renderNode: function (event, data) {
				// Optionally tweak data.node.span
				var node = data.node;
				var $span = $(node.span);
				if (node.key !=
					"_statusNode") {
					$span.find("> span.fancytree-expander").css({
						borderLeft: node.data.customLeftBorder
						//borderLeft: "1px solid orange"
					});
				}
			}
			, selectMode: 3
			, select: function (event, data) { 
				var node = data.node;
				if (node.isSelected()) {
					if (node.isUndefined()) {
						// Load
						and select all child nodes
						node.load().done(function () {
							node.visit(function (childNode) {
								childNode.setSelected(true);
							});
						});
					} else {
						// Select
						all child nodes
						node.visit(function (childNode) {
							childNode.setSelected(true);
						});
					}
				}
				else {
					//this only works when
					you click the specific node
					delMarker(node.key);
				}
				// Get a list of all selected nodes,
				and add markers
				var selKeys =
					$.map(data.tree.getSelectedNodes(), function (node) {
						if
							(node.data.treeItemType == "ent") {
								if
									(markers[node.key] == null) {
										addMarker(node.key, node.data.lat, node.data.lng,
												  node.desc, node.data.image, node.title, node.data.childImage);
									}
							}
					});
				alert("selected");
			}
			, strings: {
				loading: "Grabbing places and events…",
				loadError: "Load error!"
			}
		})
	});
}


欢迎转载,但请附上原文地址哦,尊重原创,谢谢大家 本文地址: https://www.iphpt.com/detail/38/
本站(PHP --> Golang)已重构,代码开源

当你能力不能满足你的野心的时候,你就该沉下心来学习