Skip to content

Instantly share code, notes, and snippets.

@seandogg
Created September 29, 2017 23:11
Show Gist options
  • Save seandogg/7740894f44b455488f3116484b9867f0 to your computer and use it in GitHub Desktop.
Save seandogg/7740894f44b455488f3116484b9867f0 to your computer and use it in GitHub Desktop.
IO-hidden-checkbox.liquid
{% comment %}
Conditional logic checking if the class "conditional" is checked on a checkbox,
if so, then show the text input. If not, hide it.
{% endcomment %}
<script>
window.Shoppad.apps.infiniteoptions = {
ready: function() {
$('.hidden-input').hide();
// the div has the class "conditional"...
// this is the only hack I could find to access the checkbox (there's probably a cleaner way)
// attach an ID to the checkbox so it's toggleable
$('#infiniteoptions-container > div.conditional > span > fieldset > label > input').attr('id', 'hidden');
// if checkbox is checked, toggle the hidden input
$('#hidden').click(function() {
$(".hidden-input").toggle(this.checked);
});
}
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment