最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
jquery 折叠菜单代码
时间:2009-03-23 编辑:简简单单 来源:一聚教程网
;(function($) {
function load(settings, root, child, container) {
$.getJSON(settings.url, {root: root}, function(response) {
function createNode(parent) {
var current = $("
if (this.classes) {
current.children("span").addClass(this.classes);
}
if (this.expanded) {
current.addClass("open");
}
if (this.hasChildren || this.children && this.children.length) {
var branch = $("
if (this.hasChildren) {
current.addClass("hasChildren");
createNode.call({
text:"placeholder",
id:"placeholder",
children:[]
}, branch);
}
if (this.children && this.children.length) {
$.each(this.children, createNode, [branch])
}
}
}
$.each(response, createNode, [child]);
$(container).treeview({add: child});
});
}
var proxied = $.fn.treeview;
$.fn.treeview = function(settings) {
if (!settings.url) {
return proxied.apply(this, arguments);
}
var container = this;
load(settings, "source", this, container);
var userToggle = settings.toggle;
return proxied.call(this, $.extend({}, settings, {
collapsed: true,
toggle: function() {
var $this = $(this);
if ($this.hasClass("hasChildren")) {
var childList = $this.removeClass("hasChildren").find("ul");
childList.empty();
load(settings, this.id, childList, container);
}
if (userToggle) {
userToggle.apply(this, arguments);
}
}
}));
};
})(jQuery);
-
上一个: 域名正则表达式js版,php版
-
下一个: dreamweaver 制作下拉菜单
相关文章
- 基于jQuery代码实现圆形菜单展开收缩效果 04-01
- Jquery树插件zTree实现菜单树 03-06
- jQuery实现鼠标悬停3d菜单展开动画效果的教程 02-08
- jQuery实现的省市联动菜单功能示例,亲测可用 02-04
- jQuery Collapse轻量级的手风琴菜单插件 06-14
- jQuery响应菜单插件PgwMenu使用例子 03-29