I am trying to create Customizer controls using JS API. What is a proper way to define control settings?
Here is my current code:
var mySetting = new api.Setting( 'section_title', 'Hello World!' );
api.add( mySetting );
api.control.add( new api.Control( 'section_title', {
type: 'text',
section: 'custom-section',
setting: mySetting,
label: 'Enter your custom title'
} ) );
When I try to save my changes, the Customizer shows an error: "Setting does not exist or is unrecognized."
customize_dynamic_setting_args
filter. Have a look at Weston's extensive answer on the Customizer - instantiating settings and controls via javascript question, especially the bit on creating dynamic controls.