{"id":20970106,"url":"https://github.com/h-gh/yii-js-event-handler","last_synced_at":"2026-04-18T02:10:06.256Z","repository":{"id":56984184,"uuid":"196334974","full_name":"H-Gh/yii-js-event-handler","owner":"H-Gh","description":"Using this Library you can add `custom events` to elements. Your `custom events` will run whenever you define.","archived":false,"fork":false,"pushed_at":"2019-07-13T11:39:00.000Z","size":8,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-20T04:34:37.575Z","etag":null,"topics":["event","javscript","jquery","php","yii2","yii2-asset","yii2-assets","yii2-widget","yii2-widgets"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/H-Gh.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-07-11T06:41:30.000Z","updated_at":"2019-07-13T11:38:31.000Z","dependencies_parsed_at":"2022-08-21T09:10:37.909Z","dependency_job_id":null,"html_url":"https://github.com/H-Gh/yii-js-event-handler","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H-Gh%2Fyii-js-event-handler","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H-Gh%2Fyii-js-event-handler/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H-Gh%2Fyii-js-event-handler/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/H-Gh%2Fyii-js-event-handler/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/H-Gh","download_url":"https://codeload.github.com/H-Gh/yii-js-event-handler/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243365637,"owners_count":20279215,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["event","javscript","jquery","php","yii2","yii2-asset","yii2-assets","yii2-widget","yii2-widgets"],"created_at":"2024-11-19T03:56:47.547Z","updated_at":"2026-04-18T02:10:06.165Z","avatar_url":"https://github.com/H-Gh.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n  \n    \n      \n# Yii JavaScript event handler  \nUsing this Library you can trigger your `custom events` on some another elements trigger.      \n![MIT License](https://img.shields.io/github/license/H-Gh/yii-js-event-handler.svg?style=flat-square)\n![Code Size](https://img.shields.io/github/languages/code-size/H-Gh/yii-js-event-handler.svg?style=flat-square)\n## Instalation  \n```\n composer require hgh/yii-js-event-handler\n```  \n  \n## Usage  \n### Register Yii2 Asset\n```php  \nYiiJsEventHandlerAsset::register($this);  \n```  \n\n### Instantiate jQuery Plugin\nThere are two way of instantiate this `jQuery` plugin.\n#### Use default attributes\nTo 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/) .\n```html\n\u003cdiv data-on=\"click\" data-events-to-run=\"customEvent anotherCustomEvent\"\u003e  \n```\n\n#### Define your custom attributes\nIn other hand, You can define your custom attributes. For this you have to `instantiate` `eventHandler` plugin.\n```javascript\n$(document).ready(function () {\n    $(\"[data-my-custom-on-attribute]\").eventHandler({\n        onEventAttribute: \"data-my-custom-on-attribute\",\n        toRunEventsAttribute: \"data-my-custom-to-run-events-attribute\"\n    });\n});\n```\nNow, you can use these attributes like this:\n```html\n\u003cdiv data-my-custom-on-attribute=\"click\" data-my-custom-to-run-events-attribute=\"customEvent anotherCustomEvent\"\u003e  \n```\n  \n## Sample  \n##### html  \n```html  \n\u003cdiv data-on=\"click\" data-events-to-run=\"customEvent anotherCustomEvent\"\u003e  \n Click Me to Run Custom Event\u003c/div\u003e  \n```  \n  \n##### jquery  \n```javascript  \n$(document).ready(function () {  \n  $(document).on(\"customEvent\", function () {  \n  alert(\"Custom event triggered\");  \n });  \n  $(document).on(\"anotherCustomEvent\", function () {  \n  alert(\"Another custom event triggered\");  \n });});  \n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh-gh%2Fyii-js-event-handler","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fh-gh%2Fyii-js-event-handler","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fh-gh%2Fyii-js-event-handler/lists"}