Skip to content

Instantly share code, notes, and snippets.

@Crocoblock
Created May 28, 2024 15:35
Show Gist options
  • Save Crocoblock/be965b3804879d74d6a1c43b69134534 to your computer and use it in GitHub Desktop.
Save Crocoblock/be965b3804879d74d6a1c43b69134534 to your computer and use it in GitHub Desktop.
JetFormBuilder Unselectable radio
<script>
document.addEventListener( 'DOMContentLoaded', function() {
if ( ! window?.JetPlugins?.hooks ) {
return;
}
const {
addAction,
} = window.JetPlugins.hooks;
addAction(
'jet.fb.input.makeReactive',
'unselectable-radio',
makeUnselectable
);
function makeUnselectable( input ) {
if ( ! input?.nodes?.length ) {
return;
}
if ( ! input.nodes[0].classList.contains( 'allow-unselect' ) ) {
return;
}
for ( const node of input.nodes ) {
node.addEventListener(
'click',
function() {
if ( input.value.current === this.value ) {
input.value.current = '';
}
}
);
}
}
} );
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment