I am trying to run js function when customizer section is expended and cant seem to find any event to do so.
Something like this
wp.customize.bind( 'ready', function() {
wp.customize.section.bind( 'expand', function() {
console.log('hello');
});
} );
or
wp.customize.bind( 'ready', function() {
wp.customize.section.on( 'opened', function() {
console.log('hello');
});
} );
or anything that triggers when section is active/activated/expanded/opened.
Any help is appreciated!
I am trying to run js function when customizer section is expended and cant seem to find any event to do so.
Something like this
wp.customize.bind( 'ready', function() {
wp.customize.section.bind( 'expand', function() {
console.log('hello');
});
} );
or
wp.customize.bind( 'ready', function() {
wp.customize.section.on( 'opened', function() {
console.log('hello');
});
} );
or anything that triggers when section is active/activated/expanded/opened.
Any help is appreciated!
Share Improve this question asked Oct 11, 2018 at 17:00 BennBenn 1,0431 gold badge15 silver badges32 bronze badges2 Answers
Reset to default 3Here it is
wp.customize.bind( 'ready', function() {
wp.customize.section.each( function ( section ) {
section.expanded.bind( function( isExpanding ) {
if(isExpanding){
console.log(section);
}
});
});
});
If you are targeting particular section, then you can do like:
wp.customize.section('title_tagline').expanded.bind(function (isExpanded) {
if( isExpanded ) {
// Do something here.
}
});