From 68023c098b25aeaf95473d950bbac0dcf8074d34 Mon Sep 17 00:00:00 2001 From: dabeng Date: Mon, 3 Jul 2017 17:30:05 +0800 Subject: [PATCH] feat: add initCompleted callback --- dist/js/jquery.orgchart.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/dist/js/jquery.orgchart.js b/dist/js/jquery.orgchart.js index 54645fc2..09df8670 100644 --- a/dist/js/jquery.orgchart.js +++ b/dist/js/jquery.orgchart.js @@ -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);