How to hook on customizer section expanded/active/opened event?

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!

2 Answers
2

Here it is

wp.customize.bind( 'ready', function() {

    wp.customize.section.each( function ( section ) { 

        section.expanded.bind( function( isExpanding ) {

            if(isExpanding){

                console.log(section);
            }


        });


    });
});

Leave a Comment