Skip to content

Commit

Permalink
feat: add initCompleted callback
Browse files Browse the repository at this point in the history
  • Loading branch information
dabeng committed Jul 3, 2017
1 parent 53e3459 commit 68023c0
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions dist/js/jquery.orgchart.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,22 @@
}
}
});
var mo = new MutationObserver(function (mutations) {
mo.disconnect();
initTime:
for (var i = 0; i < mutations.length; i++) {
for (var j = 0; j < mutations[i].addedNodes.length; j++) {
if (mutations[i].addedNodes[j].classList.contains('orgchart')) {
if (opts.initCompleted && typeof opts.initCompleted === 'function') {
opts.initCompleted($chart);
$chartContainer.triggerHandler({ 'type': 'init.orgchart', 'chart': $chart });
break initTime;
}
}
}
}
});
mo.observe($chartContainer[0], { childList: true });
if ($.type(data) === 'object') {
if (data instanceof $) { // ul datasource
buildHierarchy($chart, buildJsonDS(data.children()), 0, opts);
Expand Down

0 comments on commit 68023c0

Please sign in to comment.