DHTMLX Little-Known Features: “Soft-Closed” Windows

Update: This feature was deprecated. Find the latest features on the DHTMLX Window page.

One more small DHTMLX tip with the help of which you’ll be able to close window (not collapse), but it will be still active and continue working on background.

Why does someone need it? It’ll save you from the necessity to load the definite part of information each time, i.e. the work with your app will render faster.

soft-closed-windows

So, to achieve it, we use the following algorithm:

function showWindow(id, text) {
   
    // step 1 - init windows on first attempt to show window
    if (myWindows == null) {
        myWindows = new dhtmlXWindows();
    }
   
    // step 2 - check if window already inited
    if (myWindows.window(id) == null) {
       
        // window not inited yet, init new one and configure
        var w1 = myWindows.createWindow(....);
       
        // attach closing event, here we will hide
        // window instead of completely closing
        w1.attachEvent("onClose", function(win){
            win.hide();
            return false;
        });
       
    } else {
        // window inited, just show it
        myWindows.window(id).show();
       
    }
   
    // call init code if any
    //...
}

If you have any questions regarding this tip, feel free to leave it in the comments section below.

Advance your web development with DHTMLX

Gantt chart
Event calendar
Diagram library
30+ other JS components