forked from nhsuk-archive/cervical-screening-interim
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ba5eaed
commit 13b806a
Showing
18 changed files
with
12,667 additions
and
1,435 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* global $ */ | ||
$('body').on('submit', 'form', function (e) { | ||
// On form submit, add hidden inputs for checkboxes so the server knows if | ||
// they've been unchecked. This means we can automatically store and update | ||
// all form data on the server, including checkboxes that are checked, then | ||
// later unchecked | ||
|
||
var $checkboxes = $(this).find('input:checkbox') | ||
|
||
var $inputs = [] | ||
var names = {} | ||
|
||
$checkboxes.each(function () { | ||
var $this = $(this) | ||
|
||
if (!names[$this.attr('name')]) { | ||
names[$this.attr('name')] = true | ||
var $input = $('<input type="hidden">') | ||
$input.attr('name', $this.attr('name')) | ||
$input.attr('value', '_unchecked') | ||
$inputs.push($input) | ||
} | ||
}) | ||
|
||
$(this).prepend($inputs) | ||
|
||
console.log($inputs); | ||
|
||
|
||
}) |
Oops, something went wrong.