customizer control, ajax request and selective loading

WordPress 2 posts 2 voices

  1. Hi Justin & Fellows,

    I want to conditionally change certain controls (I can do logic using javascript, so not looking for that solution), my conditional logic is calculated on server side (maybe some external api calls as well), and loads some data.

    So I have few queries,

    1) Javascript related to controls, can I use underscore / backbone to refresh certain control only? Without reloading the whole customizer screen?

    2) Is it possible to just reload local variables registered using customize_controls_print_footer_scripts & wp_localize_script? without reloading the customizer?

    3) Or should I rely on ajax instead, to handle / load data dynamically?

  2. I haven’t really worked with the JS stuff much, but you have direct access to each control’s Backbone model:

    Something like this will give you the control:

    var myControl = wp.customize.control( 'my-control-name' );

    You should be able to update the model from there on the fly.

    I’m not really sure if that’ll help much. That whole page linked there is all of the core docs on the customizer, which is really lacking.