From: Joshua Rüsweg Date: Mon, 18 Jun 2018 21:50:59 +0000 (+0200) Subject: Fix missing event binding for new userTrophyOverlayList elements X-Git-Tag: 3.1.4~24 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f449f0f832cb02c9a4279cde961776db3eaae623;p=GitHub%2FWoltLab%2FWCF.git Fix missing event binding for new userTrophyOverlayList elements --- diff --git a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Trophy/List.js b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Trophy/List.js index 864883c1c2..7e655e4c57 100644 --- a/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Trophy/List.js +++ b/wcfsetup/install/files/js/WoltLabSuite/Core/Ui/User/Trophy/List.js @@ -6,7 +6,7 @@ * @license GNU Lesser General Public License * @module WoltLabSuite/Core/Ui/User/Trophy/List */ -define(['Ajax', 'Core', 'Dictionary', 'Dom/Util', 'Ui/Dialog', 'WoltLabSuite/Core/Ui/Pagination'], function(Ajax, Core, Dictionary, DomUtil, UiDialog, UiPagination) { +define(['Ajax', 'Core', 'Dictionary', 'Dom/Util', 'Ui/Dialog', 'WoltLabSuite/Core/Ui/Pagination', 'Dom/ChangeListener', 'List'], function(Ajax, Core, Dictionary, DomUtil, UiDialog, UiPagination, DomChangeListener, List) { "use strict"; /** @@ -19,14 +19,30 @@ define(['Ajax', 'Core', 'Dictionary', 'Dom/Util', 'Ui/Dialog', 'WoltLabSuite/Cor */ init: function() { this._cache = new Dictionary(); + this._knownElements = new List(); this._options = { className: 'wcf\\data\\user\\trophy\\UserTrophyAction', parameters: {} }; + this._rebuild(); + + DomChangeListener.add('WoltLabSuite/Core/Ui/User/Trophy/List', this._rebuild.bind(this)); + + + }, + + /** + * Adds event userTrophyOverlayList elements. + */ + _rebuild: function() { elBySelAll('.userTrophyOverlayList', undefined, (function (element) { - element.addEventListener(WCF_CLICK_EVENT, this._open.bind(this, elData(element, 'user-id'))); + if (!this._knownElements.has(element)) { + element.addEventListener(WCF_CLICK_EVENT, this._open.bind(this, elData(element, 'user-id'))); + + this._knownElements.add(element); + } }).bind(this)); }, @@ -39,7 +55,7 @@ define(['Ajax', 'Core', 'Dictionary', 'Dom/Util', 'Ui/Dialog', 'WoltLabSuite/Cor _open: function(userId, event) { event.preventDefault(); - this._currentPageNo = 1; + this._currentPageNo = 1; this._currentUser = userId; this._showPage(); },