From 648b96c7654d6ce01b2ed1ea1cd66dd8dafa64d3 Mon Sep 17 00:00:00 2001 From: sunhao Date: Wed, 31 Jan 2024 13:59:23 +0800 Subject: [PATCH] * zin: support to bind multiple events with single callback. --- lib/zin/core/on.class.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/zin/core/on.class.php b/lib/zin/core/on.class.php index 254c53870d..b3d511300f 100644 --- a/lib/zin/core/on.class.php +++ b/lib/zin/core/on.class.php @@ -135,7 +135,10 @@ class on extends jsCallback $selector = $this->selector ? (',' . static::json($this->selector)) : ''; $callback = parent::toJS($joiner); - return "\$element.$bindMethod('{$this->event}.zin.on'$selector,$callback);"; + $events = array_map(function($event){return $event . '.zin.on';}, explode('_', $this->event)); + $events = implode(' ', $events); + + return "\$element.$bindMethod('$events'$selector,$callback);"; } /**