jquery jstree 插件的使用
最近一个项目 需要用到jstree 这个jQuery插件,就研究了下,做目录树 菜单还是很强大的,下面对经常会用到几个用法做下说明。
1. 首先页面 引用 jquery.jstree
2. html :
- <div id="cate_tree" class="jstree fl">
- <ul>
- <li id="0" class="jstree-closed jstree-unchecked">
- <a href="#" class="jstree-clicked">
- <ins class="jstree-checkbox"> </ins>
- All Product
- </a>
- <ul style="">
- {foreach $categories as $cat}
- <li id="{$cat.id}" class="jstree-closed jstree-unchecked">
- <a href="#" class="jstree-clicked">
- <ins class="jstree-checkbox"> </ins>
- {$cat.name}
- </a>
- {if $cat.sub|@count > 0}
- <ul style="">
- {foreach $cat.sub as $subcat}
- <li id="{$subcat.id}" class="jstree-leaf jstree-unchecked">
- <a href="#" class="">
- <ins class="jstree-checkbox"> </ins>
- {$subcat.name}
- </a>
- </li>
- {/foreach}
- </ul>
- {/if}
- </li>
- {/foreach}
- </ul>
- </li>
- </ul>
- </div>
默认所有目录树打开不选中, 样式为
- class="jstree-closed jstree-unchecked">
- 默认打开目录树,样式为
- <pre name="code" class="html">class="jstree-open jstree-unchecked"></pre><pre name="code" class="html"></pre><pre name="code" class="html">默认需要全选,样式尝试</pre><pre name="code" class="html"><pre name="code" class="html">class="jstree-open jstree-checked"></pre><pre name="code" class="html"></pre><pre name="code" class="html">3. js 加载该目录树</pre><pre name="code" class="html"><pre name="code" class="javascript"></pre><pre name="code" class="javascript">// 设置jstree 主题路径
- $.jstree._themes = Www_URL_JS + 'jstree/themes/';
- $("#cate_tree").jstree({
- "plugins" : [ "themes", "html_data", "checkbox", "ui" ],
- "themes": {
- "theme": "classic",
- "dots": true,
- "icons": false
- }
- });</pre><br>
- <br>
- <pre></pre>
- <pre name="code" class="html">默认主题 是default,是文件夹样式,classic 是 + - 号的样式<pre></pre>
- <pre></pre>
- <pre></pre>
- <p></p>
- <p><br>
- </p>
- <pre></pre>
- <pre name="code" class="html">4. 获取选中的值</pre><pre name="code" class="html"><pre name="code" class="javascript"></pre><pre name="code" class="javascript">var cate_ids = [];
- $("#cate_tree .jstree-checked").each(function(){
- var $this = $(this);
- cate_ids.push($this.attr("id"));
- });</pre><br>
- <br>
- <pre></pre>
- <pre></pre>
- <pre name="code" class="html"></pre><pre></pre><pre name="code" class="html"></pre><pre name="code" class="html">5. 设置给定的值为选中状态</pre><pre name="code" class="html"><pre name="code" class="javascript"></pre><pre name="code" class="javascript">var cate_js_tree = $("#cate_tree").jstree({
- "plugins" : [ "themes", "html_data", "checkbox", "ui" ],
- "themes": {
- "theme": "classic",
- "dots": true,
- "icons": false
- }
- });
- cate_js_tree.bind('loaded.jstree', function () {
- $("#cate_tree").find("li").each(function() {
- var $this = $(this);
- for(x in cate_ids) {
- if ($this.attr("id") == cate_ids[x]) {
- $("#cate_tree").jstree("check_node", $this);
- }
- }
- });
- });</pre><br>
- <br>
- <pre></pre>
- <pre name="code" class="html">6. 如果还有不太明白的,可以访问官网查询,嘿嘿……<pre></pre><pre name="code" class="html">附上这个地址,本人觉得很不错,哈哈</pre><pre name="code" class="html">http://www.jstree.com/documentation/checkbox
- </pre>
- <p></p>
- <pre></pre>
- <pre></pre>
- <pre></pre>
- <pre></pre>
- <pre></pre>
- <pre></pre>
- <pre></pre>
- </pre></pre></pre></pre></pre></pre>
jquery jstree 插件的使用的更多相关文章
- 利用jstree插件轻松构建树应用
最近完成了项目中的一个树状应用,第一次接触了jstree这个插件,总的来说它的官方文档还是比较详细的,但是在使用过程中还是出现了一些问题,下面我就来谈谈这款插件的使用和心得. 首先项目需要构建一棵树, ...
- 顶级jQuery树插件
顶级jQuery树插件 顶级jQuery树插件 2013-03-05 17:20 139人阅读 评论(0) 收藏 举报 jsTree JsTree是一个基于jQuery的Tree控件.支持HTML.J ...
- 深入学习jQuery自定义插件
原文地址:jQuery自定义插件学习 1.定义插件的方法 对象级别的插件扩展,即为jQuery类的实例增加方法, 调用:$(选择器).函数名(参数); $(‘#id’).myPlugin(o ...
- [jQuery]jQuery DataTables插件自定义Ajax分页实现
前言 昨天在博客园的博问上帮一位园友解决了一个问题,我觉得有必要记录一下,万一有人也遇上了呢. 问题描述 园友是做前端的,产品经理要求他使用jQuery DataTables插件显示一个列表,要实现分 ...
- 使用jQuery.form插件,实现完美的表单异步提交
传送门:异步编程系列目录…… 时间真快,转眼一个月快结束了,一个月没写博客了!手开始生了,怎么开始呢…… 示例下载:使用jQuery.form插件,实现完美的表单异步提交.rar 月份的尾巴,今天的主 ...
- 为jQuery写插件
很多场合,我们都会调用jQuery的插件去完成某个功能,比如slider. 如下图,做一个div,通过“$( "#slider" ).slider();”的方式直接将div变成sl ...
- bootstrap-简洁实用的jQuery手风琴插件
前端 <html lang="zh"> <head> <meta charset="UTF-8"> <meta htt ...
- 推荐15款响应式的 jQuery Lightbox 插件
利用现代 Web 技术,网络变得越来越轻巧与.模态框是突出展现内容的重要形式,能够让用户聚焦到重要的内容上去.在这个列表中,我们编制了15款响应式的 jQuery 灯箱库,这将有助于开发人员创建和设计 ...
- Chocolat.js – 响应式的 jQuery Lightbox 插件
Chocolat.js 使您能够显示一个或多个图像在同一页面上.给用户展示一组图片缩略图,可以显示全页或块.Chocolat.js 可以很好地处理所有主要的浏览器.它在下面这些浏览器测试通过:IE7+ ...
随机推荐
- JAVA之中出现无法加载主类的情况解决方法
j今天打代码的时候出现了无法加载主类的情况,我就收集了一些,java无法加载主类的方法 ava无法加载主类解决办法 今天启动项目,又遇到找不到或无法加载主类的情况,清除项目后无法编译,class文件下 ...
- Ubuntu桌面卡死时的处理
1.这种方式可以尝试,但是不成功 sudo skill x sudo stop lightdm sudo start lightdm 2.这种方式比较可靠 ps -t tty7 kill 27342 ...
- [转]SQL Server编程:SMO介绍
转自:周公 最近在项目中用到了有关SQL Server管理任务方面的编程实现,有了一些自己的心得体会,想在此跟大家分享一下,在工作中用到了SMO/SQL CLR/SSIS等方面的知识,在国内这方面的文 ...
- javascript中数组的定义及使用
js <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.o ...
- 常用样式制作思路 自定义按钮~自适应布局~常见bug seajs简记 初学者必知的HTML规范 不容忽略的——CSS规范
常用样式制作思路 学习常用样式总结参考来自这里 带点文字链接列表利用:before实现 1 <!DOCTYPE html> 2 <html lang="en" ...
- 批量将网页转换成图片或PDF文档技巧分享
工作中我们有时要将一些批量的网页转换成图片或者PDF文档格式,尽管多数浏览器具有滚动截屏或者打印输出PDF文档功能.可是假设有几十上百张网页须要处理,那也是要人命的.所以我一直想找一款可以批量处理该工 ...
- The bytes/str dichotomy in Python 3
The bytes/str dichotomy in Python 3 - Eli Bendersky's website https://eli.thegreenplace.net/2012/01/ ...
- singlefile.py
#! encoding=utf-8 import os import os.path AllFiles = {} MinSize = 8100 def OneDir( DirName ): if Di ...
- Execution Order In a Test Plan
1.Config Element 2.Pre Processors 3.Timer 4.Sampler 5.Post Processors 6.Assertions 7.Listener
- bzoj2216
决策单调性+整体二分 这里就是j<k且kj劣于j,j不会再选,所以我们整体二分 pos是因为从L->R中这个是最优点,所以对于mid+1->r选pos之前肯定不优,l->mid ...