2
* Async Treeview 0.1 - Lazy-loading extension for Treeview
4
* http://bassistance.de/jquery-plugins/jquery-plugin-treeview/
6
* Copyright (c) 2007 Jörn Zaefferer
8
* Dual licensed under the MIT and GPL licenses:
9
* http://www.opensource.org/licenses/mit-license.php
10
* http://www.gnu.org/licenses/gpl.html
18
function load(settings, root, child, container) {
19
$.getJSON(settings.url, {root: root}, function(response) {
20
function createNode(parent) {
21
var current = $("<li/>").attr("id", this.id || "").html("<span>" + this.text + "</span>").appendTo(parent);
23
current.children("span").addClass(this.classes);
26
current.addClass("open");
28
if (this.hasChildren || this.children && this.children.length) {
29
var branch = $("<ul/>").appendTo(current);
30
if (this.hasChildren) {
31
current.addClass("hasChildren");
38
if (this.children && this.children.length) {
39
$.each(this.children, createNode, [branch])
43
$.each(response, createNode, [child]);
44
$(container).treeview({add: child});
48
var proxied = $.fn.treeview;
49
$.fn.treeview = function(settings) {
51
return proxied.apply(this, arguments);
54
load(settings, "source", this, container);
55
var userToggle = settings.toggle;
56
return proxied.call(this, $.extend({}, settings, {
60
if ($this.hasClass("hasChildren")) {
61
var childList = $this.removeClass("hasChildren").find("ul");
63
load(settings, this.id, childList, container);
66
userToggle.apply(this, arguments);
b'\\ No newline at end of file'