versteckter Link
Opleidingsdag Typ10 has a Show More shortcode which renders fine upon page load, but after filtering "onderwijsprofessionals en ondersteuners" the shortcode no longer works.
Is there a way to delay or run the Toolset script later so it does not interfere with the shortcode?
Hi,
Welcome to Toolset support. You don’t need to “delay” Toolset; you just need to re-run your Show-More JS after the View finishes its AJAX refresh. Views replaces the results’ HTML on every filter change, so any JS that was bound on page-load must be re-initialized on the new markup.
Toolset exposes front-end events for exactly this. Use them to call your Show-More init again:
1. Put your Show-More initialization in a function you can call more than once (example name here; replace with your plugin’s init code):
// Put this in a JS file or in the View's JS editor
window.hlcInitShowMore = function () {
// re-bind or (re)initialize your Show More behaviour here
// e.g. $('.show-more').showMore({...});
};
2- Call it on first load and after Toolset updates the results:
jQuery(function($){
// initial page load
if (window.hlcInitShowMore) { window.hlcInitShowMore(); }
// after a search or pagination AJAX completes for this View
$(document).on(
'js_event_wpv_parametric_search_results_updated js_event_wpv_pagination_completed',
function(event, data){
// optional: restrict to a specific View
// if (data.view_unique_id !== 'YOUR_VIEW_UNIQUE_ID') return;
if (window.hlcInitShowMore) { window.hlcInitShowMore(); }
}
);
});
These two events are the ones Toolset fires when the results have been replaced, and they’re intended for re-initializing third-party scripts.
Add the code in the View editor → Search & Pagination panel → JS editor (or a site JS file). Toolset’s “Adding custom JavaScript code to Views that use AJAX” guide shows the same pattern. For more information:
https://toolset.com/documentation/programmer-reference/adding-custom-javascript-code-to-views-that-use-ajax/
Please note: The request is considered a custom development, and the codes suggested are not tested. Those are ideas to help you find a solution. Providing a working solution is outside of our support scope.
Thanks.