Skip Navigation

[Resolved] Filters break Kadence accordion

This thread is resolved. Here is a description of the problem and solution.

Problem:

The customer experienced an issue where a Kadence accordion, used within a Toolset View block with AJAX filters, stopped functioning correctly after filtering. The accordion worked fine on the initial page load but failed to open after AJAX filtering, suggesting that the AJAX process was breaking the accordion functionality.

Solution:

The problem was caused by the Kadence Accordion's JavaScript not being reinitialized after the AJAX content load. The supporter added custom JavaScript to the View settings to reinitialize the accordion each time the AJAX filter results were updated. The JavaScript snippet used was:

jQuery(document).on('js_event_wpv_parametric_search_results_updated', function(event, data) {
    if (typeof window.KadenceBlocksAccordion !== 'undefined' && typeof window.KadenceBlocksAccordion.init === 'function') {
        window.KadenceBlocksAccordion.init();
    }
});

This solution successfully resolved the issue by ensuring the accordion's functionality was restored after each AJAX filter action.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Sao_Paulo (GMT-03:00)

Tagged: 

This topic contains 7 replies, has 2 voices.

Last updated by Mateus Getulio 4 months ago.

Assisted by: Mateus Getulio.

Author
Posts
#2725643

I have a view block in which the loop item data is inside a Kadence accordion. Also there are Ajax filters.
Now when entered in the page the accordions work fine. After filtering they don't open anymore.

If I don't use Ajax, accordions work fine after submit refresh page. So somehow Ajax breaks the accordion. Any idea how to fix this?

#2726195

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

Thank you for sharing that information.

Can you please give me an example of a page where I can experience this issue?

Also, I'd like to ask permission to make a copy/staging version of your site where I can debug this closely without affecting the live site.

I'll make sure to delete this copy as soon as we get this issue fixed.

I'm afraid of debugging directly on the live site and cause issues to your visitors. Also, it is important to test a different setup as part of the troubleshooting.

Thank you, please let us know.
Mateus

#2726716

Hi Mateus. Would you please make the next reply private so I can share you the things you asked. Thank you.

#2727075

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Sure thing.

I went ahead and marked your next reply as private.

Thank you.

#2731793
#2732091

Since this is urgent to publish now, I will send you a duplicator package of the site. We shall publish it with the proper domain and use non-ajax search and filtering there.

#2732266

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hey there,

Thank you for providing us with the duplicator package.

I'm enabling the proper field for your to share this copy, you'll see it on your next response.

Alternatively, you may use any file sharing service that you prefer and share the link in the ticket(your next response is being marked as private, only you and I have access to it).

Thank you, please let me know.

#2732783
#2733060

The search is in this packkage non-ajax, because the ajax version's kadence accordion doesn't work. But change the search to ajax so you see the problem after filtering.

#2733474

Mateus Getulio
Supporter

Languages: English (English )

Timezone: America/Sao_Paulo (GMT-03:00)

Hello there,

I checked it and it looks like the issue likely originates from the fact that after the AJAX filtering occurs, the JavaScript that controls the Kadence Accordion is not being reinitialized. When you use AJAX to filter the content, the page does not reload, which means that any JavaScript tied to the accordion, such as event listeners for the accordion's open/close functionality, does not get reapplied to the newly loaded content.

I looked into the Kadence plugins file and I was able to find the JS that gets it started in wp-content/plugins/kadence-blocks/includes/assets/js/kt-accordion.min.js

To fix the issue I added the following JavaScript directly to the View settings within that page:

jQuery( document ).on( 'js_event_wpv_parametric_search_results_updated', function( event, data ) {
	// Reinitialize Kadence Accordion after AJAX content load
    if (typeof window.KadenceBlocksAccordion !== 'undefined' && typeof window.KadenceBlocksAccordion.init === 'function') {
        window.KadenceBlocksAccordion.init();
    }
  
});

That will cause the accordion code to be reloaded everything the filter changes.

I tested it on my local site and it worked as expected, can you please test it and confirm it is fixed?

Thank you,
Mateus

#2733774

Wow Mateus, thank you so much, it works now!