Skip to content

Commit

Permalink
fixed #334
Browse files Browse the repository at this point in the history
  • Loading branch information
Atanas Atanasov committed May 2, 2018
1 parent f4c4d78 commit b55dbfd
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 12 deletions.
7 changes: 5 additions & 2 deletions dist/combined/js/gijgo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12056,8 +12056,11 @@ gj.tree.plugins.lazyLoading = {
response = JSON.parse(response);
}
if (response && response.length) {
$list = $('<ul />').addClass(data.style.list);
$node.append($list);
$list = $node.children('ul');
if ($list.length === 0) {
$list = $('<ul />').addClass(data.style.list);
$node.append($list);
}
for (i = 0; i < response.length; i++) {
$tree.addNode(response[i], $list);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/combined/js/gijgo.min.js

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions dist/modular/js/tree.js
Original file line number Diff line number Diff line change
Expand Up @@ -1322,8 +1322,11 @@ gj.tree.widget.constructor = gj.tree.widget;
response = JSON.parse(response);
}
if (response && response.length) {
$list = $('<ul />').addClass(data.style.list);
$node.append($list);
$list = $node.children('ul');
if ($list.length === 0) {
$list = $('<ul />').addClass(data.style.list);
$node.append($list);
}
for (i = 0; i < response.length; i++) {
$tree.addNode(response[i], $list);
}
Expand Down
2 changes: 1 addition & 1 deletion dist/modular/js/tree.min.js

Large diffs are not rendered by default.

15 changes: 11 additions & 4 deletions examples/tests/temptree.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,26 @@
<script src="../../dist/combined/js/gijgo.js"></script>
</head>
<body>
<button onclick="tree.addNode({ Title: 'node1'})">Add node1</button>
<button onclick="add()">Add node1</button>
<button onclick="tree.addNode({ Title: 'node1-1' }, tree.getNodeByText('node1'))">Add node1-1</button>
<button onclick="alert(tree.getNodeByText('node1').html())">Get node1</button>
<div id="tree"></div>
<script>
var tree;
$(document).ready(function () {
$('#tree').tree({
tree = $('#tree').tree({
primaryKey: 'id',
dataSource: '/Locations/LazyGet',
lazyLoading: true,
checkboxes: true
lazyLoading: true
});
});
function add() {
var nodeId = tree.getSelections()[0];
var parent = tree.getNodeById(nodeId);
tree.expand(parent);
tree.addNode({ id: 77, text: "new folder", url: "", lazy: true, icon: "" }, parent);
}

</script>
</body>
</html>
7 changes: 5 additions & 2 deletions src/tree/js/tree.lazyLoading.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,11 @@ gj.tree.plugins.lazyLoading = {
response = JSON.parse(response);
}
if (response && response.length) {
$list = $('<ul />').addClass(data.style.list);
$node.append($list);
$list = $node.children('ul');
if ($list.length === 0) {
$list = $('<ul />').addClass(data.style.list);
$node.append($list);
}
for (i = 0; i < response.length; i++) {
$tree.addNode(response[i], $list);
}
Expand Down

0 comments on commit b55dbfd

Please sign in to comment.