Fixed orphan language dropdown breaking new ones
authorAlexander Ebert <ebert@woltlab.com>
Sun, 14 Dec 2014 01:20:55 +0000 (02:20 +0100)
committerAlexander Ebert <ebert@woltlab.com>
Sun, 14 Dec 2014 01:20:55 +0000 (02:20 +0100)
wcfsetup/install/files/js/WCF.js

index 53c2e17198adf9a26b6ac82c1502f3422722f6ce..9232769c5323017dbdb844d08e5e88d343e1c138 100755 (executable)
@@ -1293,6 +1293,24 @@ WCF.Dropdown = {
                for (var $i = 0, $length = this._callbacks[containerID].length; $i < $length; $i++) {
                        this._callbacks[containerID][$i](containerID, action);
                }
+       },
+       
+       /**
+        * Destroies an existing dropdown menu.
+        * 
+        * @param       string          containerID
+        * @return      boolean
+        */
+       destroy: function(containerID) {
+               if (this._dropdowns[containerID] === undefined) {
+                       return false;
+               }
+               
+               this.close(containerID);
+               
+               this._menus[containerID].remove();
+               delete this._menus[containerID];
+               delete this._dropdowns[containerID];
        }
 };
 
@@ -10590,6 +10608,7 @@ WCF.Language.Chooser = Class.extend({
                        this._dropdown.children('.dropdownToggle').empty().append($dropdownToggle);
                }
                
+               WCF.Dropdown.destroy(containerID + '-languageChooser');
                WCF.Dropdown.init();
        },