Problem hiding - showing a window with a form

Hello, I’m facing with a stupid problem with a window that goes on error when hidden and then showed again.
The simplyfied example:

Snippet Tool

I have a window and attach a form to it. When I open the window the first time, all seems pretty. But if I cancel input (window.hide()) and then recall it (window.show()), then I face a wonderful “script error”.
In my main project, the firefox debugger tells: ‘Uncaught TypeError: can’t access property “_node”, el is null’ and the form is not displayed.

Can you help me, please?

Hi, your problem is using the afterHide event to clear your form. I can’t explain why this happens; I imagine it’s due to the internal functioning of the components in the window, layout, and form, when working with DOM and events. But for this to work, you can use the beforeHide event, which works normally, or within afterHide, you use the awaitRedraw function, and within that, clear your form:

        // use beforeHide event
        dhxwindow.events.on("beforeHide", function() {
            frmQ.clear();
        });
        // or use awaitRedraw into afterHide event
        dhxwindow.events.on("afterHide", function() {
            dhx.awaitRedraw().then(() => {
                frmQ.clear();
            });
        });

Here’s an adjusted snippet:
https://snippet.dhtmlx.com/mrk9i9c6

Hope this helps.

Solved, thank you very much

1 Like