mirror of
https://github.com/psychopy/psychojs.git
synced 2025-05-10 10:40:54 +00:00
Dialogs now properly destroyed and removed from DOM when closed
Ensures dialogs are immediately removed from DOM when closed. Previously, dialogs were destroyed but not removed causing possibility of duplicate element IDs, so jQuery unitentionally selects and recreates old dialogs, thus GUI._updateOkButtonStatus updates the wrong button.
This commit is contained in:
parent
88827706ea
commit
584d76a04f
@ -255,6 +255,7 @@ export class GUI
|
||||
// close is called by both buttons and when the user clicks on the cross:
|
||||
close: function () {
|
||||
//$.unblockUI();
|
||||
$(this).dialog('destroy').remove();
|
||||
self._dialogComponent.status = PsychoJS.Status.FINISHED;
|
||||
}
|
||||
|
||||
@ -313,8 +314,6 @@ export class GUI
|
||||
showOK = true,
|
||||
onOK
|
||||
} = {}) {
|
||||
// destroy previous dialog box:
|
||||
this.destroyDialog();
|
||||
|
||||
let htmlCode;
|
||||
let titleColour;
|
||||
@ -410,7 +409,7 @@ export class GUI
|
||||
id: "buttonOk",
|
||||
text: "Ok",
|
||||
click: function() {
|
||||
$(this).dialog("close");
|
||||
$(this).dialog("destroy").remove();
|
||||
|
||||
// execute callback function:
|
||||
if (typeof onOK !== 'undefined')
|
||||
@ -504,24 +503,6 @@ export class GUI
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Destroy the currently opened dialog box.
|
||||
*
|
||||
* @name module:core.GUI#dialog
|
||||
* @function
|
||||
* @public
|
||||
*/
|
||||
destroyDialog()
|
||||
{
|
||||
if ($("#expDialog").length) {
|
||||
$("#expDialog").dialog("destroy");
|
||||
}
|
||||
if ($("#msgDialog").length) {
|
||||
$("#msgDialog").dialog("destroy");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Listener for resource event from the [Server Manager]{@link ServerManager}.
|
||||
*
|
||||
|
@ -387,9 +387,6 @@ export class PsychoJS
|
||||
// close the window:
|
||||
self._window.close();
|
||||
|
||||
// destroy dialog boxes:
|
||||
self._gui.destroyDialog();
|
||||
|
||||
// remove everything from the browser window:
|
||||
while (document.body.hasChildNodes())
|
||||
document.body.removeChild(document.body.lastChild);
|
||||
|
Loading…
Reference in New Issue
Block a user