PHPackages                             hgh/yii-js-event-handler - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hgh/yii-js-event-handler

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hgh/yii-js-event-handler
========================

Using this library, You can define custom events and trigger them on other events trigger.

1.1.1(6y ago)011MITJavaScript

Since Jul 11Pushed 6y agoCompare

[ Source](https://github.com/H-Gh/yii-js-event-handler)[ Packagist](https://packagist.org/packages/hgh/yii-js-event-handler)[ Docs](https://github.com/H-Gh/yii-js-event-trigger)[ RSS](/packages/hgh-yii-js-event-handler/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (2)Versions (6)Used By (1)

Yii JavaScript event handler
============================

[](#yii-javascript-event-handler)

Using this Library you can trigger your `custom events` on some another elements trigger.
[![MIT License](https://camo.githubusercontent.com/327f9ab5f84ccbf3f931dd24caa2aad0918b8772ecea8648b32dd36c39b2be1c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f482d47682f7969692d6a732d6576656e742d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/327f9ab5f84ccbf3f931dd24caa2aad0918b8772ecea8648b32dd36c39b2be1c/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f482d47682f7969692d6a732d6576656e742d68616e646c65722e7376673f7374796c653d666c61742d737175617265)[![Code Size](https://camo.githubusercontent.com/422aaf7bc96950c8ecdf5b6725a1c3c57f25c22c872b4a5c6dd2a58c34323dab/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f482d47682f7969692d6a732d6576656e742d68616e646c65722e7376673f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/422aaf7bc96950c8ecdf5b6725a1c3c57f25c22c872b4a5c6dd2a58c34323dab/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f482d47682f7969692d6a732d6576656e742d68616e646c65722e7376673f7374796c653d666c61742d737175617265)

Instalation
-----------

[](#instalation)

```
 composer require hgh/yii-js-event-handler

```

Usage
-----

[](#usage)

### Register Yii2 Asset

[](#register-yii2-asset)

```
YiiJsEventHandlerAsset::register($this);
```

### Instantiate jQuery Plugin

[](#instantiate-jquery-plugin)

There are two way of instantiate this `jQuery` plugin.

#### Use default attributes

[](#use-default-attributes)

To use default options you have to add two predefined attribute to your `html` element. You put your custom `JS` events into `data-events-to-run`. Separate your `custom events` using `space`. Then using `data-on` specify when these `custom events` should be trigger. The values that you can put in `data-on` follows `jQuery` events. Visit [Form events](https://api.jquery.com/category/events/form-events/), [Mouse events](https://api.jquery.com/category/events/mouse-events/) and [keyboard events](https://api.jquery.com/category/events/keyboard-events/) .

```

```

#### Define your custom attributes

[](#define-your-custom-attributes)

In other hand, You can define your custom attributes. For this you have to `instantiate` `eventHandler` plugin.

```
$(document).ready(function () {
    $("[data-my-custom-on-attribute]").eventHandler({
        onEventAttribute: "data-my-custom-on-attribute",
        toRunEventsAttribute: "data-my-custom-to-run-events-attribute"
    });
});
```

Now, you can use these attributes like this:

```

```

Sample
------

[](#sample)

##### html

[](#html)

```

 Click Me to Run Custom Event
```

##### jquery

[](#jquery)

```
$(document).ready(function () {
  $(document).on("customEvent", function () {
  alert("Custom event triggered");
 });
  $(document).on("anotherCustomEvent", function () {
  alert("Another custom event triggered");
 });});
```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity1

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

5

Last Release

2493d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7873222f18ced9739dd54f5bcfa13a8d9738496d22b38ff35d9f4b5b84f3269b?d=identicon)[h.gh](/maintainers/h.gh)

---

Top Contributors

[![H-Gh](https://avatars.githubusercontent.com/u/32479577?v=4)](https://github.com/H-Gh "H-Gh (19 commits)")

---

Tags

eventjavscriptjqueryphpyii2yii2-assetyii2-assetsyii2-widgetyii2-widgetsphpjavascriptjqueryyii2

### Embed Badge

![Health badge](/badges/hgh-yii-js-event-handler/health.svg)

```
[![Health](https://phpackages.com/badges/hgh-yii-js-event-handler/health.svg)](https://phpackages.com/packages/hgh-yii-js-event-handler)
```

###  Alternatives

[fedemotta/yii2-widget-datatables

DataTables widget for Yii2

34179.4k1](/packages/fedemotta-yii2-widget-datatables)[richardfan1126/yii2-js-register

Yii2 widget to register JS into view

1357.2k7](/packages/richardfan1126-yii2-js-register)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
