Testing for presence of Gantt Chart

Hello,

I have designed a fully customised lightbox for the Gantt chart which submits data via the dataprocessor.

However in my application this lightbox form can be opened independently of the Gantt chart, which is not loaded on all pages.

How can I test for the presence of the Gantt chart and add/edit tasks to the DataProcessor if it is loaded or else submit via alternative ajax process if it is not loaded?

Thanks,
Tim

Hi,
the component defines a couple of global objects when it’s loaded on the page. So you can check them:function isGanttLoaded(){ return !!(window.gantt); }

Hi,

Unfortunately this function is always returning true, even if the Gantt chart is not loaded. The JS file is included on every page.

I need to know if the gantt has been initialized because one of my interface elements refreshes the gantt chart view after collapsing.

It works great when the gantt chart is loaded on the page, but if it is not loaded I get “Uncaught TypeError: Cannot read property ‘boxSizing’ of null”

Is there another way to detect if the Gantt has been initialized?

Thanks,
Tim

Hi,
try checking if gantt have ‘$container’ property. When gantt in initialized, this property points to the html container where control is rendered

function isGanttLoaded(){ return !!(window.gantt && gantt.$container); }

Thanks Aliaksandr,

That works perfectly!

Have a nice day