Skip to content

Instantly share code, notes, and snippets.

@marcusig
Created January 17, 2022 12:50
Show Gist options
  • Save marcusig/936e688ab07ce166aa24574cb4cce490 to your computer and use it in GitHub Desktop.
Save marcusig/936e688ab07ce166aa24574cb4cce490 to your computer and use it in GitHub Desktop.
JS Action to execute code when a choice is changed.
// Requires wp.hooks
// Make sure to set 'wp-hooks' and 'jquery' as dependencies when loading this script.
if ( ! wp || ! wp.hooks ) return;
( function( $ ) {
wp.hooks.addAction( 'PC.fe.choice.set_choice', 'Custom_domain', function( model, view ) {
// Do something here.
// view.$el will give you the jQuery object of the current choice.
} );
} )( jQuery );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment