Last active
November 11, 2016 17:06
-
-
Save salsalabs/9abf8841ad1afe98e2bece8b42eacdac to your computer and use it in GitHub Desktop.
Script to correctly handle clicks on optional groups. An optional group needs to have a value in 'linkKey' no matter what. Salsa does not do this correctly and sometimes the wrong optional group is recorded. This script assures campaign managers that a clicked optional group either contains the groups_KEY or a zero.
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
<script type="text/javascript"> | |
// Script to handle clicks on optional groups. | |
function optionalClick(event) { | |
var elem = event.target; | |
elem.value = elem.checked ? elem.getAttribute('alt-value') : 0; | |
} | |
// Find and configure all optional groups. | |
document.addEventListener("DOMContentLoaded", function() { | |
Array.from(document.querySelectorAll('input[id^="add_to_groups_KEY"]')).forEach(function(e) { | |
e.setAttribute('alt-value', e.getAttribute('value')); | |
e.addEventListener('change', optionalClick); | |
}); | |
}); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment