{"id":16718183,"url":"https://github.com/allouis/add-view-events","last_synced_at":"2025-10-13T04:04:50.155Z","repository":{"id":57173249,"uuid":"44011168","full_name":"allouis/add-view-events","owner":"allouis","description":"💥 Standalone event delegation for views 💥","archived":false,"fork":false,"pushed_at":"2015-10-12T09:15:52.000Z","size":128,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-23T04:20:37.388Z","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/allouis.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2015-10-10T13:12:34.000Z","updated_at":"2016-11-16T11:23:17.000Z","dependencies_parsed_at":"2022-08-24T14:41:11.249Z","dependency_job_id":null,"html_url":"https://github.com/allouis/add-view-events","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allouis%2Fadd-view-events","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allouis%2Fadd-view-events/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allouis%2Fadd-view-events/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allouis%2Fadd-view-events/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allouis","download_url":"https://codeload.github.com/allouis/add-view-events/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243713420,"owners_count":20335567,"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-10-12T21:35:36.655Z","updated_at":"2025-10-13T04:04:45.134Z","avatar_url":"https://github.com/allouis.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# add-view-events\n\nAdds delegated event listeners to an element, optionally binding the callbacks to a context, allows for easy removal of event listeners on cleanup\n\n```\nnpm install add-view-events\n```\n\n## Usage\n\n```javascript\nvar addEvents = require('./add-view-events')\n\nfunction SomeView() {\n  this.el = document.createElement('div')\n  this.removeEvents = addEvents(this.el, {\n      'click button.some-class': this.shout\n  }, this)\n}\n\nSomeView.prototype.shout = function() {\n  alert(this.msg)\n}\n\nSomeView.prototype.remove = function() {\n  this.removeEvents()\n  this.el.remove()\n}\n```\n\n## API\n\n#### `addEvents(el, events[, context])`\n\nAttach event listeners and returns a cleanup function. `el` should be an element, `events` should be an object with `'event elem.selector'` keys and function properties.\n\nThe `context` argument is optional and will ensure callbacks are called with their context bound to `context`\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallouis%2Fadd-view-events","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallouis%2Fadd-view-events","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallouis%2Fadd-view-events/lists"}