https://github.com/pocesar/angular-event-delegate
Use a common parent to delegate events to underlaying DOM elements using jQuery
https://github.com/pocesar/angular-event-delegate
Last synced: over 1 year ago
JSON representation
Use a common parent to delegate events to underlaying DOM elements using jQuery
- Host: GitHub
- URL: https://github.com/pocesar/angular-event-delegate
- Owner: pocesar
- License: mit
- Created: 2014-08-24T22:45:27.000Z (almost 12 years ago)
- Default Branch: master
- Last Pushed: 2016-10-22T22:04:10.000Z (over 9 years ago)
- Last Synced: 2024-10-18T06:28:02.769Z (over 1 year ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 7
- Watchers: 4
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
angular-event-delegate
======================
Use a common parent to delegate events to underlaying DOM elements using jQuery.
[DEMO](http://plnkr.co/edit/wTjaeI9RAoPwy4Nkycwk?p=preview)
Usage
=================
```js
angular
.module('App', ['EventDelegate'])
.controller('MainCtrl', function(){
this.items = [
{name: 'name', value: 'value', showy: false},
{name: 'two' , value: '2', showy: false}
];
this.clicky = function(value){
alert(value);
};
});
```
```html
```
## How is it better than ng-click?
You can define, at once, many events besides click event, on the parent that will be delegated to the elements inside it.
Any new elements added to the parent will have the event bound without the need to binding a new event to it. Also useful with a big list of elements, having 100+ event listeners attached to each item, plus scope.$watch'es, starts to feel heavy. This is mainly useful in `ng-repeat` loops though.
You can define multiple selectors as well using for example `'click': '.showcase,.infotext'`
## Requirements
This depends on jQuery