{"id":23053475,"url":"https://github.com/component/events","last_synced_at":"2025-07-22T20:02:27.324Z","repository":{"id":6019192,"uuid":"7242787","full_name":"component/events","owner":"component","description":"High level dom node event management (with delegation support)","archived":false,"fork":false,"pushed_at":"2016-12-22T13:31:25.000Z","size":26,"stargazers_count":36,"open_issues_count":4,"forks_count":14,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-28T12:15:28.250Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/component.png","metadata":{"files":{"readme":"Readme.md","changelog":"History.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-12-19T15:34:40.000Z","updated_at":"2025-01-16T06:12:44.000Z","dependencies_parsed_at":"2022-09-26T17:00:53.580Z","dependency_job_id":null,"html_url":"https://github.com/component/events","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/component/events","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fevents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fevents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fevents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fevents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/component","download_url":"https://codeload.github.com/component/events/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/component%2Fevents/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265016793,"owners_count":23698372,"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":[],"created_at":"2024-12-16T00:18:19.561Z","updated_at":"2025-07-12T16:04:49.167Z","avatar_url":"https://github.com/component.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\n# events\n\n  Higher level dom event management with direct and delegate event handling support.\n\n  This component makes subscription management easy and unobtrusive since it does not muck with your view prototypes. Unbinding to \"clean up\" after your view is as simple as invoking `this.events.unbind()`, or more specific unbinds may be performed.\n\n  It's design to work with a \"host\" object, typically a view, that provides callbacks, making callback management much less tedious than libraries like jQuery.\n\n## Installation\n\n    $ component install component/events\n\n## Example\n\n```js\nvar events = require('events');\nvar el = document.querySelector('.user');\n\nvar view = new UserView(el);\n\nfunction UserView(el) {\n  this.events = events(el, this);\n  this.events.bind('click .remove', 'remove');\n  this.events.bind('click .hide', 'hide');\n}\n\nUserView.prototype.remove = function(){\n  // remove the user\n  this.hide();\n};\n\nUserView.prototype.hide = function(){\n  // hide the view\n};\n\nUserView.prototype.destroy = function(){\n  // clean up anything you need to\n  this.events.unbind();\n};\n```\n\n## API\n\n### Events(el, obj)\n\n  Initialize a new events manager targetting the\n  given element. Methods are delegated to `obj`.\n\n### Events#bind(event, [method])\n\n  Bind direct event handlers or delegates with `event` and\n  invoke `method` when the event occurs, passing the event object.\n  When `method` is not defined the `event` name prefixed with \"on\" is used.\n\n  For example the following will invoke `onmousedown`, `onmousemove`,\n  and `onmouseup`:\n\n```js\nevents.bind('mousedown')\nevents.bind('mousemove')\nevents.bind('mouseup')\n```\n\n  Alternatively you may specify the `method` name:\n\n```js\nevents.bind('click', 'toggleDisplay')\n```\n\n  To use event delegation simply pass a selector after the\n  event name as shown here:\n\n```js\nevents.bind('click .remove', 'remove')\nevents.bind('click .close', 'hide')\n```\n\n  You may bind to the same element with several events if necessary,\n  for example here perhaps `.remove()` does not manually invoke `.hide()`:\n\n```js\nevents.bind('click .remove', 'remove')\nevents.bind('click .remove', 'hide')\nevents.bind('click .close', 'hide')\n```\n\n  Addition arguments are passed to the callee, which\n  is helpful for slight variations of a method, for\n  example sorting:\n\n```js\nevents.bind('click .sort-asc', 'sort', 'asc')\nevents.bind('click .sort-dsc', 'sort', 'dsc')\n```\n\n### Events.unbind([event], [method])\n\n  There are three flavours of unbinding -- you may unbind _all_\n  event handlers, all specific to `event`, or all specific to\n  `event` and the given `method`. For example these are all valid:\n\n```js\nevents.unbind('click', 'remove')\nevents.unbind('click', 'hide')\nevents.unbind('click')\nevents.unbind()\n```\n\n## License\n\n  MIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fevents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcomponent%2Fevents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcomponent%2Fevents/lists"}