Changed node find method from data- attributes to jquery data()
This maintains validation on pre-HTML5 documentsmaster
parent
f1432f80d2
commit
b034e9900d
|
@ -69,11 +69,14 @@
|
||||||
// Drop event handler for nodes
|
// Drop event handler for nodes
|
||||||
$('div.node').bind("drop", function handleDropEvent( event, ui ) {
|
$('div.node').bind("drop", function handleDropEvent( event, ui ) {
|
||||||
|
|
||||||
var targetLi = $this.find("[data-tree-node=" + $(this).data("tree-node") + "]");
|
var targetID = $(this).data("tree-node");
|
||||||
var sourceLi = $this.find("[data-tree-node=" + ui.draggable.data("tree-node") + "]");
|
var targetLi = $this.find("li").filter(function() { return $(this).data("tree-node") === targetID; } );
|
||||||
|
var targetUl = targetLi.children('ul');
|
||||||
|
|
||||||
|
var sourceID = ui.draggable.data("tree-node");
|
||||||
|
var sourceLi = $this.find("li").filter(function() { return $(this).data("tree-node") === sourceID; } );
|
||||||
var sourceUl = sourceLi.parent('ul');
|
var sourceUl = sourceLi.parent('ul');
|
||||||
|
|
||||||
var targetUl = targetLi.children('ul');
|
|
||||||
if (targetUl.length > 0){
|
if (targetUl.length > 0){
|
||||||
targetUl.append(sourceLi);
|
targetUl.append(sourceLi);
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,9 +127,9 @@
|
||||||
|
|
||||||
//Increaments the node count which is used to link the source list and the org chart
|
//Increaments the node count which is used to link the source list and the org chart
|
||||||
nodeCount++;
|
nodeCount++;
|
||||||
$node.attr("data-tree-node", nodeCount);
|
$node.data("tree-node", nodeCount);
|
||||||
$nodeDiv = $("<div>").addClass("node")
|
$nodeDiv = $("<div>").addClass("node")
|
||||||
.attr("data-tree-node", nodeCount)
|
.data("tree-node", nodeCount)
|
||||||
.append($nodeContent);
|
.append($nodeContent);
|
||||||
|
|
||||||
// Expand and contract nodes
|
// Expand and contract nodes
|
||||||
|
|
|
@ -69,11 +69,14 @@
|
||||||
// Drop event handler for nodes
|
// Drop event handler for nodes
|
||||||
$('div.node').bind("drop", function handleDropEvent( event, ui ) {
|
$('div.node').bind("drop", function handleDropEvent( event, ui ) {
|
||||||
|
|
||||||
var targetLi = $this.find("[data-tree-node=" + $(this).data("tree-node") + "]");
|
var targetID = $(this).data("tree-node");
|
||||||
var sourceLi = $this.find("[data-tree-node=" + ui.draggable.data("tree-node") + "]");
|
var targetLi = $this.find("li").filter(function() { return $(this).data("tree-node") === targetID; } );
|
||||||
|
var targetUl = targetLi.children('ul');
|
||||||
|
|
||||||
|
var sourceID = ui.draggable.data("tree-node");
|
||||||
|
var sourceLi = $this.find("li").filter(function() { return $(this).data("tree-node") === sourceID; } );
|
||||||
var sourceUl = sourceLi.parent('ul');
|
var sourceUl = sourceLi.parent('ul');
|
||||||
|
|
||||||
var targetUl = targetLi.children('ul');
|
|
||||||
if (targetUl.length > 0){
|
if (targetUl.length > 0){
|
||||||
targetUl.append(sourceLi);
|
targetUl.append(sourceLi);
|
||||||
} else {
|
} else {
|
||||||
|
@ -124,9 +127,9 @@
|
||||||
|
|
||||||
//Increaments the node count which is used to link the source list and the org chart
|
//Increaments the node count which is used to link the source list and the org chart
|
||||||
nodeCount++;
|
nodeCount++;
|
||||||
$node.attr("data-tree-node", nodeCount);
|
$node.data("tree-node", nodeCount);
|
||||||
$nodeDiv = $("<div>").addClass("node")
|
$nodeDiv = $("<div>").addClass("node")
|
||||||
.attr("data-tree-node", nodeCount)
|
.data("tree-node", nodeCount)
|
||||||
.append($nodeContent);
|
.append($nodeContent);
|
||||||
|
|
||||||
// Expand and contract nodes
|
// Expand and contract nodes
|
||||||
|
|
Loading…
Reference in New Issue