From 3bc1e08d463a64fafe25ff78589fa689f9cce4ae Mon Sep 17 00:00:00 2001 From: sunhao Date: Fri, 12 Jan 2024 17:25:48 +0800 Subject: [PATCH] * core: support to bind inited event globally. --- lib/core/src/helpers/global-event.ts | 2 +- lib/core/src/helpers/zui-creator.ts | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/core/src/helpers/global-event.ts b/lib/core/src/helpers/global-event.ts index 3a9dbe3977..9b065073df 100644 --- a/lib/core/src/helpers/global-event.ts +++ b/lib/core/src/helpers/global-event.ts @@ -92,4 +92,4 @@ function handleGlobalEvent(this: Cash, event: Event) { } } -$(document).on('click.helpers.zt change.helpers.zt', '[data-on]', handleGlobalEvent); +$(document).on('click.global.zui change.global.zui inited.global.zui', '[data-on]', handleGlobalEvent); diff --git a/lib/core/src/helpers/zui-creator.ts b/lib/core/src/helpers/zui-creator.ts index 92a29e30fc..c99c46a38c 100644 --- a/lib/core/src/helpers/zui-creator.ts +++ b/lib/core/src/helpers/zui-creator.ts @@ -91,6 +91,12 @@ $.fn.zuiInit = function (this: Cash) { }); this.find('.hide-before-init').removeClass('invisible hidden opacity-0'); this.find('.scroll-into-view').scrollIntoView(); + this.find('[data-on="inited"]').each((_, ele) => { + const $ele = $(ele); + if (!$ele.zui()) { + $ele.trigger('inited'); + } + }); return this; };