From 0822dc0325cf664327bf8bb73d96e9ededb5a539 Mon Sep 17 00:00:00 2001 From: IvanNaum Date: Mon, 27 May 2024 12:22:52 +0300 Subject: [PATCH] =?UTF-8?q?=D1=84=D0=B8=D0=BA=D1=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Components/ChatInput/ChatInput.js | 7 ++++++- src/Components/Sticker/Sticker.js | 10 ---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/src/Components/ChatInput/ChatInput.js b/src/Components/ChatInput/ChatInput.js index 26de9a4..5fb8aa2 100644 --- a/src/Components/ChatInput/ChatInput.js +++ b/src/Components/ChatInput/ChatInput.js @@ -15,10 +15,15 @@ export default class ChatInput extends BaseComponent { '.popup_stickers_body', ); this.getConfig().stickers.forEach((sticker) => { - sticker.handler = this.getConfig().stickerSendHandler; const stickerBlock = new Sticker(stickersBlock, sticker); stickerBlock.render(); }); + stickersBlock.addEventListener('click', (event) => { + const target = event.target; + + const stickerId = parseInt(target.id.match(/\d+$/)[0]); + this.getConfig().stickerSendHandler(stickerId); + }); } render() { diff --git a/src/Components/Sticker/Sticker.js b/src/Components/Sticker/Sticker.js index 44b0f37..77bf263 100644 --- a/src/Components/Sticker/Sticker.js +++ b/src/Components/Sticker/Sticker.js @@ -2,14 +2,4 @@ import { BaseComponent } from '../BaseComponent.js'; export default class Sticker extends BaseComponent { templateName = 'Sticker'; - - render() { - super.render(); - - this.getParent() - .querySelector(`#sticker_img_${this.getConfig().sticker_id}`) - .addEventListener('click', () => { - this.getConfig().handler(this.getConfig().sticker_id); - }); - } }