`
Enn
  • 浏览: 28339 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

Jstree 1.0.2rc Config

阅读更多
$(function () {
	$("#search").click(function () {
        $("#taxon_tree").jstree("search",$("#search_str").val());
    });

	$("#taxon_tree")
	.jstree({ 
		"plugins" : [ "themes", "html_data", "search", "crrm", "contextmenu", "types"],
		"contextmenu" :	{
			items:{
				edit : false,
				"New" : {
					// The item label
					"label"	: "New material",
					// The function to execute upon a click
					"action" : function (obj) {
						$.ajax({
						   	type: 'GET',
						   	url: "/materials/" + obj.attr("id") +"/new_material",
						   	success : function (r) {
						   		if(!r.status) {
									$('#new_material').html(r);
						   		}
						   	},
						 	error : function (r) {
								alert("can't be blank");
							}
						});
					},
					// All below are optional 
					"_disabled"	: false,		// clicking the item won't do a thing
					"_class"	: "class",	// class is applied to the item LI node
					"separator_before"	: false,	// Insert a separator before the item
					"separator_after"	: true,		// Insert a separator after the item
					// false or string - if does not contain `/` - used as classname
					"icon"		: false,
				}
			}
		},
		"types" : {
			// I set both options to -2, as I do not need depth and children count checking
			// Those two checks may slow jstree a lot, so use only when needed
			"max_depth" : -2,
			"max_children" : -2,
			// I want only `drive` nodes to be root nodes 
			// This will prevent moving or creating any other type as a root node
			"valid_children" : [ "drive" ],
			"types" : {
				// The default type
				"file" : {
					// I want this type to have no children (so only leaf nodes)
					// In my case - those are files
					"valid_children" : "none",
					// If we specify an icon for the default type it WILL OVERRIDE the theme icons
					"icon" : {
						"image" : "/images/rails.png"
					}
				},
				// The `folder` type
				"folder" : {
					// can have files and other folders inside of it, but NOT `drive` nodes
					"valid_children" : [ "default", "folder" ],
					"icon" : {
						"image" : "/images/grid.png"
					}
				},
				// The `drive` nodes 
				"drive" : {
					// can have files and folders inside, but NOT other `drive` nodes
					"valid_children" : [ "default", "folder" ],
					"icon" : {
						"image" : "/static/v.1.0rc2/_demo/root.png"
					},
					// those options prevent the functions with the same name to be used on the `drive` type nodes
					// internally the `before` event is used
					"start_drag" : false,
					"move_node" : false,
					"delete_node" : false,
					"remove" : false
				}
			}
		},
	})
	.bind("create.jstree", function (e, data) {
	   $.ajax({
		   	type: 'POST',
		   	url: "/taxons",
		   	data : { 
		   		"taxon[name]" : data.rslt.name ,
		   		"taxon[taxonomy_id]" : data.rslt.parent.attr("name") ,
				"parent" : data.rslt.parent.attr("id")
		   	}, 
		   	success : function (r) {
		   		if(!r.status) {
		   			data.inst.refresh();
		   		}
		   	},
		 	error : function (r) {
				alert("can't be blank");
			}
		});
	})
	.bind("rename.jstree", function (e, data) {
	   $.ajax({
		   	type: 'PUT',
		   	url: "/taxons/" + data.rslt.obj.attr("id"),
		   	data : { 
		   		"taxon[name]" : data.rslt.new_name
		   	}, 
		   	success : function (r) {
		   		if(!r.status) {
		   			data.inst.refresh();
		   		}
		   	},
		 	error : function (r) {
				alert("can't be blank");
			}
	 	});
	})
	.bind("remove.jstree", function (e, data) {
		$.ajax({
			type: 'DELETE',
			url: "/taxons/" + data.rslt.obj.attr("id"),
			success : function (r) {
				if(!r.status) {
					data.inst.refresh();
				}
			},
			error : function (r) {
				alert("Something wrong");
			}
		});
	});
});

分享到:
评论
1 楼 ccue 2011-02-21  
我用jstree +struts2.18 ajax 不能访问后台action 用juery$.post一样的url都可以访问数据
 <script type="text/javascript">
            
            $(document).ready(function(){
                $.post("../admin/ajax/matterCategoryTree.action", {pid:1}, function(data, textStatus){
                       
                    }, "json");
                $("#LeftSideBody").jstree({
                    "plugins": ["themes", "json_data", "ui"],
                    "json_data": {
                        "ajax": {
                            "url": "../admin/ajax/matterCategoryTree.action",
                            "data": function(n){                  
                                return {
                                    pid: n.attr ? n.attr("id").replace("node_", "") : false
                                };
                            }
                        }
                    }
                });
            });
        </script>

相关推荐

    Python库 | gcastle-1.0.2rc1-py3-none-any.whl

    `gcastle-1.0.2rc1-py3-none-any.whl` 是一个针对Python的库,它是软件分发和安装的便捷形式。下面我们将详细探讨这个库及其相关知识点。 首先,`gcastle` 是一个Python库的名字,1.0.2rc1 表示这是该库的1.0.2版本...

    Python库 | twisted_iocpsupport-1.0.2rc0-cp38-cp38-win_amd64.whl

    资源分类:Python库 所属语言:Python 使用前提:需要解压 资源全名:twisted_iocpsupport-1.0.2rc0-cp38-cp38-win_amd64.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    PyPI 官网下载 | gcastle-1.0.2rc1-py3-none-any.whl

    资源来自pypi官网。 资源全名:gcastle-1.0.2rc1-py3-none-any.whl

    atmosphere-gwt-js-1.0.2-sources.jar

    atmosphere-gwt-js-1.0.2-sources.jar

    Python库 | awkward-1.0.2rc1-cp35-cp35m-win_amd64.whl

    资源分类:Python库 所属语言:Python 资源全名:awkward-1.0.2rc1-cp35-cp35m-win_amd64.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    Python库 | manim_revealjs-1.0.2-py3-none-any.whl

    python库。 资源全名:manim_revealjs-1.0.2-py3-none-any.whl

    web-socket-js-1.0.2.zip_flash js websocket_web scoket.js_websock

    在“web-socket-js-1.0.2.zip”这个压缩包中,包含的是一个用于实现WebSocket在旧版浏览器,特别是IE8上兼容性的解决方案。 WebSocket协议在HTML5规范中引入,提供了全双工、低延迟的通信渠道,但早期的浏览器,如...

    sprintf.js-1.0.2.zip

    这个1.0.2版本的库,为JavaScript开发者提供了类似于C语言中printf函数的功能,极大地丰富了JavaScript中的字符串处理能力。 sprintf.js的核心功能在于其对格式化字符串的支持,允许开发者指定输出字符串的格式,...

    Proj4js 1.0.2 js脚本 库

    **Proj4js 1.0.2:JavaScript 地图投影转换库** Proj4js 是一个开源的 JavaScript 库,它的主要功能是处理地理坐标系统的投影转换。在地图制图领域,不同地区、不同用途的地图可能采用不同的投影方式,Proj4js 提供...

    js-o4w.1.0.2

    "js-o4w.1.0.2" 是一个由开发者JinWen创建的JavaScript主题包,版本为1.0.2。这个主题包可能是专门为网页开发设计的,用于增强网页的外观和用户体验。从标签中我们可以看到,它不仅包含了"js-o4w.1.0.2"的标识,还...

    JS数独 v1.0.2

    《JS数独 v1.0.2》是一款基于JavaScript实现的数独小游戏,适用于现代浏览器,尤其是基于WebKit内核的浏览器如Chrome或Safari。在IE浏览器中,部分验证功能可能无法正常工作,但不影响基本的游戏体验。这个项目展示...

    Python库 | dkist_data_simulator-1.0.2rc3.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:dkist_data_simulator-1.0.2rc3.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    openssl-1.0.2u + openssl-1.0.2k

    标题中的"openssl-1.0.2u + openssl-1.0.2k"指的是OpenSSL库的两个不同版本,1.0.2u和1.0.2k。OpenSSL是一个开源项目,提供安全套接层(SSL)和传输层安全(TLS)协议的实现,用于加密通信,确保网络数据传输的安全...

    PyPI 官网下载 | jsConsole-1.0.2.tar.gz

    **PyPI 官网下载 | jsConsole-1.0.2.tar.gz** PyPI(Python Package Index)是Python程序员发布自己开发的库或模块的主要平台,它为全球Python开发者提供了丰富的资源,使得安装和分享Python软件包变得极其方便。本...

    openssl 1.0.2p源码

    1. 加密算法:OpenSSL 支持多种加密算法,如 AES(高级加密标准)、DES(数据加密标准)、3DES(三重DES)、Blowfish、RC4 等。这些算法用于加密和解密数据,防止未经授权的访问。 2. 密钥管理:OpenSSL 支持密钥的...

    Python库 | jsengine-1.0.2.tar.gz

    资源分类:Python库 所属语言:Python 资源全名:jsengine-1.0.2.tar.gz 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    libwebp-1.0.2-rc1-windows-x64.zip

    这个“libwebp-1.0.2-rc1-windows-x64.zip”文件包含的是libwebp库的1.0.2 Release Candidate 1版本,适用于64位Windows操作系统。在这个压缩包中,你可以找到一系列用于开发的文件,帮助你在Windows环境中集成和...

Global site tag (gtag.js) - Google Analytics