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

| Comments (2)

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

Click to open live demo

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
    //...
}

Here you can find the demo with the whole source code. If you have any questions regarding this tip, feel free to leave it in the comments section below.

Comments

  1. khalid abd alla April 5, 2015 at 4:56 pm

    Dear Sir,
    the live demo is not working , the lib is not added
    Uncaught ReferenceError: dhtmlXWindows is not defined

    • Ivan (DHTMLX team) April 6, 2015 at 2:48 pm

      Hello, it seems that the demo works fine. You may contact us at support@dhtmlx.com – we’ll send you this demo as .zip archive so you could open it locally.

Leave a Reply