jQuery: The Write Less, Do More JavaScript Library

Ticket #2830: treeview_click_href.patch

File treeview_click_href.patch, 1.0 kB (added by jyrki, 3 months ago)

Patch to enable href and click options

  • jquery.treeview.async.js

     
    1818function load(settings, root, child, container) { 
    1919    $.getJSON(settings.url, {root: root}, function(response) { 
    2020        function createNode(parent) { 
    21             var current = $("<li/>").attr("id", this.id || "").html("<span>" + this.text + "</span>").appendTo(parent); 
     21            var current = $("<li/>").attr("id", this.id || "").html("<span></span>"); 
     22            if (this.click || this.href) { 
     23                current.children("span").html("<a />");  
     24                current.find("a").attr("href", this.href || "#"); 
     25                if (this.click) { 
     26                    var fn = this.click; 
     27                    current.find("a").click(function() { 
     28                        eval(fn); 
     29                    }); 
     30                } 
     31                current.find("a").html(this.text); 
     32            } else { 
     33                current.children("span").html(this.text); 
     34            } 
     35            current.appendTo(parent); 
    2236            if (this.classes) { 
    2337                current.children("span").addClass(this.classes); 
    2438            }