winbox
winbox copied to clipboard
Does window with same title already exist ?
Hi I plan to open winboxes via buttons, each button will open a winbox with a specific title.
Is it possible to check if a winbox with that title already exists ? If it does bring to front and focus the winbox, if not open it.
Thanks
I've sort of got this working. I've added jquery to check the open div's titles, but I'm struggling to bring into focus a window of the same name if it is found. Any ideas ?
$(document).ready(function() {
$("body").on('click', '#add', function(){
$('div[id^=winbox]').each(function(i, obj) {
var openWindow = $(obj).find('.wb-title').text();
if ( openWindow = 'name' ) {
WinBox.focus( obj.id );
return false
}
});
// add new window
var Modal = new WinBox('name', {
url: "https://127.0.0.1/newpage.php"
})
})
})
It is simple like that:
const win = {};
function openWindow(title){
if(win[title]) win[title].focus();
else win[title] = new WinBox(title);
}
openWindow("foo");
openWindow("bar");
openWindow("foo");