Fixed dialog destruction
authorAlexander Ebert <ebert@woltlab.com>
Tue, 4 Jul 2017 15:08:50 +0000 (17:08 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Tue, 4 Jul 2017 15:08:50 +0000 (17:08 +0200)
wcfsetup/install/files/js/WoltLabSuite/Core/Ui/Dialog.js

index 0cb1ce245653459b5445ecf35316fee8760e22e0..a8eeeda0baca465a7f2caca23a0d3d6c158b4c55 100644 (file)
@@ -620,15 +620,22 @@ define(
                /**
                 * Destroys a dialog instance.
                 * 
-                * @param       {(string|object)}       id      element id or callback object
+                * @param       {Object}        callbackObject  the same object that was used to invoke `_dialogSetup()` on first call
                 */
-               destroy: function(id) {
-                       id = this._getDialogId(id);
-                       if (this.isOpen(id)) {
-                               this.close(id);
+               destroy: function(callbackObject) {
+                       if (typeof callbackObject !== 'object' || callbackObject instanceof String) {
+                               throw new TypeError("Expected the callback object as parameter.");
                        }
                        
-                       _dialogs.delete(id);
+                       if (_dialogObjects.has(callbackObject)) {
+                               var id = _dialogObjects.get(callbackObject).id;
+                               if (this.isOpen(id)) {
+                                       this.close(id);
+                               }
+                               
+                               _dialogs.delete(id);
+                               _dialogObjects.delete(callbackObject);
+                       }
                },
                
                /**