I want to show a dialog window that contains a dhx form, where the form data comes from a remote source.
So I want to show ajax scroller while fetching the data and display nothing until the form is created in the window and then make the window visible.
Currently I am using the code below to achieve this - is this the best approach or is there a better way?
//Code here to build dhxWindowObj, a window object that one div for html content as below
//<div> id='divOpen'></div>
ShowAjaxScroller();
//Code here to fetch and build form_data that will be used further down
dhxWindow.events.on("afterShow", function() {
//Keep the window and it's overlay hidden until all content is loaded
dhxWindow.getContainer().style.visibility = "hidden";
$('.dhx_window__overlay').css("visibility", "hidden");
//Wait for the window with it's div to be created
dhx.awaitRedraw().then(() => {
//Build form in the window
//It is only after 'awaitRedraw' that 'divOpen' is available
var dhxForm = new dhx.Form('divOpen', form_data);
//Finally show the window
dhxWindowObj.getContainer().style.visibility = "visible";
$('.dhx_window__overlay').css("visibility", "visible");
HideAjaxScroller();
})
});
dhxWindowObj.show();