Problem:
A JavaScript library is used to add a masonry layout for posts output with a View. After custom search or pagination the masonry effect no longer happens.
Solution:
The masonry code is initially loaded with the DOM ready event. It needs to be reinitialised when the View output has been replaced using ajax (because of a search or pagination).
The precise requirements depend on what library is being used, but the code to initialise the JS library should be structured something like this, which uses custom JS events available with Views. These custom events can be found in the JS editor of the Search and Pagination section of the View using the Frontend events button.
// 1. Define a function that does "the thing" function theThing() { //do the thing } (function ($) { // 2. Do the thing on initial pageload (DOM ready) $(document).ready(function () { theThing(); }); // 3. Do the thing after ajax custom search $(document).on('js_event_wpv_parametric_search_results_updated', function (event, data) { theThing(); }); })(jQuery);
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 |
---|---|---|---|---|---|---|
- | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | 7:00 – 14:00 | - |
- | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | 15:00 – 16:00 | - |
Supporter timezone: Europe/London (GMT+00:00)
This topic contains 2 replies, has 2 voices.
Last updated by 5 years, 4 months ago.
Assisted by: Nigel.