Skip to content

Commit

Permalink
Use SelectionButtons live selector, for JS/AJAX content
Browse files Browse the repository at this point in the history
Some GOV.UK pages, like Smart Answers, load content via JS, including
radio buttons or checkboxes. These will be added to the DOM after the
selector is run and the resulting elements are passed to SelectionButtons

SelectionButtons can also take a string selector and use document
events (alphagov/govuk_frontend_toolkit#139)
so use that and any JS loaded content  will get the behaviour too.
  • Loading branch information
David Singleton committed Jan 26, 2015
1 parent e6d49e1 commit 758b309
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions app/assets/javascripts/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ $(document).ready(function() {
}

// for radio buttons and checkboxes
var $buttons = $("label.selectable input[type='radio'], label.selectable input[type='checkbox']");
new GOVUK.SelectionButtons($buttons);
var buttonsSelector = "label.selectable input[type='radio'], label.selectable input[type='checkbox']";
new GOVUK.SelectionButtons(buttonsSelector);
});


0 comments on commit 758b309

Please sign in to comment.