Here the question: how to hook in custom code (function) just after selective refresh has been made?
Luckely, the developers of WP have added several events which are trigger in certain moments of work of this relatively new feature of WP Customizer. They are:
Events (triggered on wp.customize.selectiveRefresh):
I needed precisely partial-content-rendered
event, so this is a code I used (with the check of what exactly part of the content was rendered):
wp.customize.selectiveRefresh.bind( 'partial-content-rendered', function( placement ) { if ( placement.partial.id === '...id of the customizer setting...' ) { console.log('do smth!'); // add your code here! } } );
Of course, it is required to add this code into the file that will be enqueued when Customizer is being loaded.