Skip to content

Commit 68023c0

Browse files
committed
feat: add initCompleted callback
1 parent 53e3459 commit 68023c0

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

dist/js/jquery.orgchart.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,22 @@
8686
}
8787
}
8888
});
89+
var mo = new MutationObserver(function (mutations) {
90+
mo.disconnect();
91+
initTime:
92+
for (var i = 0; i < mutations.length; i++) {
93+
for (var j = 0; j < mutations[i].addedNodes.length; j++) {
94+
if (mutations[i].addedNodes[j].classList.contains('orgchart')) {
95+
if (opts.initCompleted && typeof opts.initCompleted === 'function') {
96+
opts.initCompleted($chart);
97+
$chartContainer.triggerHandler({ 'type': 'init.orgchart', 'chart': $chart });
98+
break initTime;
99+
}
100+
}
101+
}
102+
}
103+
});
104+
mo.observe($chartContainer[0], { childList: true });
89105
if ($.type(data) === 'object') {
90106
if (data instanceof $) { // ul datasource
91107
buildHierarchy($chart, buildJsonDS(data.children()), 0, opts);

0 commit comments

Comments
 (0)