alphagov/govuk_frontend_toolkit — pull request #139 by tombye (2014-10-13 10:39:15+00:00)
Title: Add document level events to selection buttons

The current version of `GOVUK.selectionButtons` (see https://github.com/alphagov/govuk_frontend_toolkit/pull/121) works by taking a jQuery-wrapped collection of DOM nodes as the first parameter, and binding events to them:

```
var $buttons = $("label input[type='radio'], label input[type='checkbox']");
GOVUK.selectionButtons($buttons);
```

This sometimes doesn't work on pages where the HTML is replaced by AJAX because the elements those events are bound to may no longer be in the page.
This pull request (PR) gives `GOVUK.selectionButtons` the ability to take a [selector string](http://api.jquery.com/category/selectors/) instead, which it uses to assign a [live event](http://api.jquery.com/live/) to the document:

```
GOVUK.selectionButtons("label input[type='radio'], label input[type='checkbox']");
```

This means once you've called `GOVUK.selectionButtons`, any changes to the content of the page will not effect the functionality. This is backwards-compatible, the existing interface is still supported.

This PR also includes a rewrite of the tests for selection-buttons. The previous ones were too tied to the implementation and didn't describe the requirements very well.