Home / Archive / Rerender PDF Viewer when embedded inside Kadence Blocks > Tabs for PDF Embedder Lite
Duplicate Snippet

Embed Snippet on Your Site

Rerender PDF Viewer when embedded inside Kadence Blocks > Tabs for PDF Embedder Lite

When you add a PDF Embedder block or shortcode inside the Tabs block of the Kadence Blocks plugin, you need to make sure the viewer is always takes the full content of the tab and is properly rendered.

Code Preview
php
<?php
add_action( 'wp_footer', static function () {
	?>
	<script>
		const tabTitles = document.querySelectorAll( '.kt-tab-title' );
		for ( const tabTitle of tabTitles ) {
			tabTitle.addEventListener( 'click', function() {
				let tabs = tabTitle.closest( '.kt-tabs-wrap' );
				let tabNumber = tabTitle.classList.value.match( /kt-tab-title-\d+/ )[ 0 ].replace( 'kt-tab-title-', '' );
				setTimeout( function() {
					jQuery( '.kt-inner-tab-' + tabNumber + ' .pdfemb-viewer', tabs ).pdfEmbedder( pdfemb_trans.cmap_url );
				}, 300 );
			} );
		}
	</script>
	<?php
} );

Comments

Add a Comment