HEX
Server: nginx/1.18.0
System: Linux mail.dakarash.co.id 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User: www-data (33)
PHP: 8.1.2-1ubuntu2.23
Disabled: NONE
Upload Files
File: /home/dakarash.co.id/public_html/plugins/visual-portfolio/gutenberg/blocks/loop/view.js
import $ from 'jquery';

const $doc = $(document);

// Define the block selectors we need to replace after ajax loading.
const blockSelectors = [
	'.vp-block-filter-by-category',
	'.vp-block-sort',
	'.vp-block-pagination',
];

$doc.on('loadedNewItems.vpf', function (event, vpObject, $newVP) {
	if ('vpf' !== event.namespace) {
		return;
	}

	if (!vpObject.$item.closest('.vp-block-loop').length) {
		return;
	}

	const $currentLoop = vpObject.$item.closest('.vp-block-loop');
	const $newLoop = $newVP.closest('.vp-block-loop');

	// For each block type, find and replace them maintaining order
	blockSelectors.forEach((selector) => {
		const $currentBlocks = $currentLoop.find(selector);
		const $newBlocks = $newLoop.find(selector);

		// Replace each block in order
		$currentBlocks.each(function (index) {
			const $currentBlock = $(this);
			const $newBlock = $newBlocks.eq(index);

			// Only replace if we have a corresponding new block
			if ($newBlock.length) {
				$currentBlock.replaceWith($newBlock);
			}
		});
	});
});