EasyUI Forum
November 04, 2025, 08:03:42 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: How to get an active window and close in easyui desktop extension?  (Read 14181 times)
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« on: February 24, 2019, 03:41:15 AM »

How do I close an active dialog in easyui desktop. I know it is possible to close it by its ID but I want to close just the active window using js code. This was we can close the active window by using keyboard shortcut key. Please help. I want to know how I would get the active window (desktop dialog) using js.

The following code checks whether the dialog is created but it uses ID selector and does not particularly target active dialog.

Code:
$('#dlg').data('dialog')

But how do I target an active dialog and not using ID selector.

Thanks and regards,

Alfred
« Last Edit: February 24, 2019, 06:18:06 AM by Alfred » Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #1 on: February 24, 2019, 07:43:40 AM »

Please try this code to get all the opened windows.
Code:
var apps = $('body').desktop('options').apps;
var openedApps = apps.filter(function(app){
return app.win && !app.win.dialog('options').closed;
});
console.log(openedApps)
Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #2 on: February 24, 2019, 08:05:05 AM »

Please can you give an example on how I would select the active window and close it.

Thanks.
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #3 on: February 25, 2019, 02:37:20 AM »

Call this code to close all the opened windows.
Code:
var apps = $('body').desktop('options').apps;
var openedApps = apps.filter(function(app){
return app.win && !app.win.dialog('options').closed;
});
for(var i=0; i<openedApps.length; i++){
openedApps[i].win.dialog('close')
}
Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #4 on: February 25, 2019, 02:56:49 AM »

It works great. But I have one more request. Why does not it close the dialog created using function? I really appreciate your help.

Code:
function singleCollect(){
    $('body').desktop('openApp', {
        id:'scollection',
    name: '',
        icon: '../images/get.png',
        width: 290, 
        href: 'template/single.php',
        bodyCls: 'panel-noscroll'
    });
}

Thanks

Alfred
Logged
stworthy
Administrator
Hero Member
*****
Posts: 3581


View Profile Email
« Reply #5 on: February 25, 2019, 07:12:08 PM »

This code closes all the opened windows.
Code:
var openedApps = $('body').desktop('getOpenedApps');
for(var i=0; i<openedApps.length; i++){
openedApps[i].win.dialog('close')
}
Logged
Alfred
Full Member
***
Posts: 134


-Licensed User-


View Profile
« Reply #6 on: February 25, 2019, 09:31:31 PM »

Thanks it works..
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!