wp customizer js preview – use setting based on other setting

I’m quite green at wp js framework;

What i’m trying to achieve is that if setting 123 == a then assign setting_x to .header-banner background-color; else if setting 123 == b assign value of setting_y.

To help understand my problem better below is the code for wp customizer api

customizer-preview.js

header_option = wp.customize(‘123’).get();
if(header_option ==”a”){
wp.customize(‘setting_x’, function (value){
value.bind (function(newval){
$(‘.header-banner’).css(‘background-color’, newval);
});
});
} else{
wp.customize(‘setting_y’ ,function (value){
value.bind ( function (newval){
$(‘.header-banner’).css(‘background-color’, newval);
});
});
}

I would appreciate an explanation as search wp debugger / codex pages didn’t get me very far, hence my question here

Read more here:: wp customizer js preview – use setting based on other setting

Leave a Reply

Your email address will not be published. Required fields are marked *