渲染html标签

来自ling
跳转至: 导航搜索
// @Bind #treeExamples.onRenderNode
!function(arg) {
	var node = arg.node, data = node.get("data"), xCreateConfig = [];
	arg.dom.style.fontWeight = (data.get("hot") ? "bold" : "");
 
	if (node.get("bindingConfig.name") == "category") {
		xCreateConfig.push({
			tagName : "SPAN",
			contentText : node.get("label")
		});
		xCreateConfig.push({
			tagName : "SPAN",
			contentText : "(" + data.get("childCount") + ")",
			style : "margin-left: 2px; color: gray"
		});
		if (data.get("new")) {
			xCreateConfig.push({
				tagName : "IMG",
				src : $url(">images/new.gif"),
				style : "position: relative; left: 4px; top: 4px"
			});
		}
	} else {
		if (data.get("new")) {
			xCreateConfig.push({
				tagName : "SPAN",
				contentText : node.get("label")
			});
			xCreateConfig.push({
				tagName : "IMG",
				src : $url(">images/new.gif"),
				style : "position: relative; left: 4px; top: 4px"
			});
			xCreateConfig.push({
				tagName: "A",
				href: "version.view.ManageBusinessDictView.ling?businessDictId=" + arg.data.get("businessDictId"),
				content: "业务词典表维护"
			});
		}
	}
 
	if (xCreateConfig.length) {
		$(arg.dom).empty().xCreate(xCreateConfig);
	} else {
		arg.processDefault = true;
	}
}