Skip to content

Instantly share code, notes, and snippets.

@jeremywrowe
Created November 16, 2013 14:55
Show Gist options
  • Save jeremywrowe/7500996 to your computer and use it in GitHub Desktop.
Save jeremywrowe/7500996 to your computer and use it in GitHub Desktop.
This is an example of limiting selection of a set of on/off components on Chargify hosted pages to select only a single component. This script can be utilized by adding it to your "Custom Javascript" on the "Hosted Pages Settings" found under the "Settings" tab. Example Video: http://cl.ly/2237413N071y/on-off-components-single-selection.mov
$(function() {
var updatingCheckboxes = false,
$components = $('.component-checkbox');
$components.change(function(e) {
if(updatingCheckboxes) { return; }
var $el = $(this),
checked = $el.attr("checked");
if(checked) {
e.preventDefault();
updatingCheckboxes = true;
$components.attr("checked", false);
$el.attr("checked", true);
updatingCheckboxes = false;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment