issue #8: clicking links inside nodes doesn't collapse nodes now.

master
Wes 2012-03-16 14:38:11 +00:00
parent fb6808bd07
commit c27039a9b3
2 changed files with 70 additions and 64 deletions

View File

@ -49,6 +49,7 @@
<ul> <ul>
<li id="beer">Beer</li> <li id="beer">Beer</li>
<li>Vegetables <li>Vegetables
<a href="http://wesnolte.com" target="_blank">Click me</a>
<ul> <ul>
<li>Pumpkin</li> <li>Pumpkin</li>
<li> <li>

View File

@ -147,7 +147,6 @@
// Method that recursively builds the tree // Method that recursively builds the tree
function buildNode($node, $appendTo, level, opts) { function buildNode($node, $appendTo, level, opts) {
var $table = $("<table cellpadding='0' cellspacing='0' border='0'/>"); var $table = $("<table cellpadding='0' cellspacing='0' border='0'/>");
var $tbody = $("<tbody/>"); var $tbody = $("<tbody/>");
@ -168,7 +167,7 @@
.end() .end()
.html(); .html();
var new_node_id = $node.attr("id") var new_node_id = $node.attr("id");
if (typeof new_node_id !== 'undefined' && new_node_id !== false) { if (typeof new_node_id !== 'undefined' && new_node_id !== false) {
$nodeDiv = $("<div>").addClass("node").attr("id", $node.attr("id")).append($nodeContent); $nodeDiv = $("<div>").addClass("node").attr("id", $node.attr("id")).append($nodeContent);
}else{ }else{
@ -259,6 +258,12 @@
$table.append($tbody); $table.append($tbody);
$appendTo.append($table); $appendTo.append($table);
/* Prevent trees collapsing if a link inside a node is clicked */
$nodeDiv.children('a').click(function(e){
console.log(e);
e.stopPropagation();
});
}; };
})(jQuery); })(jQuery);