<commit_before># data-action

Bind all sorts of things to html click events to build your own UI framework.

[![Dependency Status](https://gemnasium.com/ForbesLindesay/data-action.png)](https://gemnasium.com/ForbesLindesay/data-action)
[![NPM version](https://badge.fury.io/js/data-action.png)](http://badge.fury.io/js/data-action)

[![browser support](https://ci.testling.com/ForbesLindesay/data-action.png)](https://ci.testling.com/ForbesLindesay/data-action)

## Installation

    npm install data-action

## Usage

Define actions, along with 'before' and 'after' hooks.  Each hook may return a promise, and if it does the promise will be waited on before the next handler is called.  This means you could make an AJAX call to update something, and then refresh the current page:

```js
var dataAction = require('data-action');
var actions = dataAction();

actions.before('[data-confirm]', function (element, parents) {
  if (!confirm(element.getAttribute('data-confirm'))) {
    throw new Error('action cancelled by user');
  }
});<commit_msg>Use http://shields.io for README badges.<commit_after># data-action

Bind all sorts of things to html click events to build your own UI framework.

[![Dependency Status](https://img.shields.io/gemnasium/ForbesLindesay/data-action.svg)](https://gemnasium.com/ForbesLindesay/data-action)
[![NPM version](https://img.shields.io/npm/v/data-action.svg)](http://badge.fury.io/js/data-action)

[![browser support](https://ci.testling.com/ForbesLindesay/data-action.png)](https://ci.testling.com/ForbesLindesay/data-action)

## Installation

    npm install data-action

## Usage

Define actions, along with 'before' and 'after' hooks.  Each hook may return a promise, and if it does the promise will be waited on before the next handler is called.  This means you could make an AJAX call to update something, and then refresh the current page:

```js
var dataAction = require('data-action');
var actions = dataAction();

actions.before('[data-confirm]', function (element, parents) {
  if (!confirm(element.getAttribute('data-confirm'))) {
    throw new Error('action cancelled by user');
  }
});
{'fraction_non_alphanumeric': 0.13857677902621723, 'fraction_numerical': 0.0, 'mean_word_length': 4.83879781420765, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 10, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5138559', 'n_tokens_mistral': 676, 'n_tokens_neox': 651, 'n_words': 192}