Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

customizer control deactivation using JavaScrip API

$
0
0

Replies: 0

I have 2 customizer controls, the first is a radio type.
I enqueued my script using “customize_controls_enqueue_scripts” hook
I want the second control to appear/disappear based on the first control’s value.
my javascript is:

wp.customize.bind("ready", function () {
  var customize = this;
  customize("setting_name", function (setting) {
    setting.bind('change',function (value) {
      if(value=='desired_value'){
        wp.customize.control('second_control').activate()
    }
      else{
        wp.customize.control('second_control').deactivate()
    }
    });
  });
});

this works ! hoever couple of seconds letter the preview window refreshes and the second control just gets reactivated on its own.
in absence of Javascript APIs documentation, is there someone who can explain this behavior to me or how to fix the issue ? thanks


Viewing all articles
Browse latest Browse all 59525

Trending Articles