diff --git a/examples/js/jquery.orgchart.js b/examples/js/jquery.orgchart.js index f7f4a7a2..b8338f1d 100644 --- a/examples/js/jquery.orgchart.js +++ b/examples/js/jquery.orgchart.js @@ -32,6 +32,7 @@ }; var opts = $.extend(defaultOptions, options); + this.data('orgchart', { 'options' : opts }); switch (options) { case 'buildNode': @@ -374,19 +375,20 @@ // create node function createNode(nodeData, opts) { // construct the content of node - var $nodeDiv = $('
', {'id': nodeData[opts.nodeId]}) + var $nodeDiv = $('
', { 'id': nodeData[opts.nodeId] }) .addClass('node') .append('
' + nodeData[opts.nodeTitle] + '
') .append(typeof opts.nodeContent !== 'undefined' ? '
' + nodeData[opts.nodeContent] + '
' : ''); // append 4 directions arrows - if (Number(nodeData[opts.nodeRelationship].substr(0,1))) { + var flags = nodeData[opts.nodeRelationship]; + if (Number(flags.substr(0,1))) { $nodeDiv.append(''); } - if(Number(nodeData[opts.nodeRelationship].substr(1,1))) { + if(Number(flags.substr(1,1))) { $nodeDiv.append('' + ''); } - if(Number(nodeData[opts.nodeRelationship].substr(2,1))) { + if(Number(flags.substr(2,1))) { $nodeDiv.find('.title').prepend('') $nodeDiv.append(''); } @@ -859,7 +861,7 @@ // Construct the node var $nodeRow = $("").addClass("node-cells"); var $nodeCell = $("").addClass("node-cell").attr("colspan", 2); - var $nodeDiv = createNode(nodeData, opts); + var $nodeDiv = createNode(nodeData, opts ? opts : this.data('orgchart').options); $nodeCell.append($nodeDiv); $nodeRow.append($nodeCell); $tbody.append($nodeRow); diff --git a/jquery.orgchart.js b/jquery.orgchart.js index f7f4a7a2..b8338f1d 100644 --- a/jquery.orgchart.js +++ b/jquery.orgchart.js @@ -32,6 +32,7 @@ }; var opts = $.extend(defaultOptions, options); + this.data('orgchart', { 'options' : opts }); switch (options) { case 'buildNode': @@ -374,19 +375,20 @@ // create node function createNode(nodeData, opts) { // construct the content of node - var $nodeDiv = $('
', {'id': nodeData[opts.nodeId]}) + var $nodeDiv = $('
', { 'id': nodeData[opts.nodeId] }) .addClass('node') .append('
' + nodeData[opts.nodeTitle] + '
') .append(typeof opts.nodeContent !== 'undefined' ? '
' + nodeData[opts.nodeContent] + '
' : ''); // append 4 directions arrows - if (Number(nodeData[opts.nodeRelationship].substr(0,1))) { + var flags = nodeData[opts.nodeRelationship]; + if (Number(flags.substr(0,1))) { $nodeDiv.append(''); } - if(Number(nodeData[opts.nodeRelationship].substr(1,1))) { + if(Number(flags.substr(1,1))) { $nodeDiv.append('' + ''); } - if(Number(nodeData[opts.nodeRelationship].substr(2,1))) { + if(Number(flags.substr(2,1))) { $nodeDiv.find('.title').prepend('') $nodeDiv.append(''); } @@ -859,7 +861,7 @@ // Construct the node var $nodeRow = $("").addClass("node-cells"); var $nodeCell = $("").addClass("node-cell").attr("colspan", 2); - var $nodeDiv = createNode(nodeData, opts); + var $nodeDiv = createNode(nodeData, opts ? opts : this.data('orgchart').options); $nodeCell.append($nodeDiv); $nodeRow.append($nodeCell); $tbody.append($nodeRow);