Created
November 16, 2013 14:55
-
-
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
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
$(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