Changing the entire control choices using wp.customize with JavaScript

You’re close. You just need to replace changeTheChoices() with set() as this is a method on wp.customize.Setting. See the following which also refactors a bit:

wp.customize( 'setting_category', 'setting_font', function( categorySetting, fontSetting ) {
    categorySetting.bind( function( category ) {
        var newChoices = {};
        // get new data from JSON using 'category' and populate the 'newChoices'

        fontSetting.set( newChoices );
    });
});

Tip: I suggest not using “setting” in the IDs for your settings.

Leave a Comment