An open API service indexing awesome lists of open source software.

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

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

Click: [ {{ item.name }} ]


Toggle on mouseenter
Showing


```

## 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