Skip Navigation

[Resolved] Load more button to view with search filter

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

Problem:
Want to add Load more button to view with search filter.
Solution:
Here is steps in screenshots:
https://toolset.com/forums/topic/load-more-button-to-view-with-search-filter/#post-616823
Relevant Documentation:

This support ticket is created 6 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 12:00 – 17:00 -
- 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 18:00 – 21:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 4 replies, has 3 voices.

Last updated by simon buerman 6 years, 9 months ago.

Assisted by: Noman.

Author
Posts
#616716

Hello i added a Load more button to a view to load de custom post type 6 by 6 . for the main page that works great but if i click to a filter. all the custom post type disapear

here my function in function.php

jQuery(document).ready(function () {
size_li = jQuery("#myList li").size();
x=6;
jQuery('#myList li:lt('+x+')').show();
jQuery('#loadMore').click(function () {
x= (x+6 <= size_li) ? x+6 : size_li;
jQuery('#myList li:lt('+x+')').show();
});
jQuery('#showLess').click(function () {
x=(x-6<1) ? 6 : x-6;
jQuery('#myList li').not(':lt('+x+')').hide();
});

});

how can i do to applicate this function in each filter categories ?

#616738

We cannot debug such custom code, but I suspect, the issue is due to AJAX loading of the View results.

If you use a View with any form of AJAX updating involved, often you need to re-initiate your own Custom JS after the AJAX events happened.
That can be done in the View's Filter JS Editor Section.

There you can click "Front end events" and add your custom JS Function in the wrapper API function generated by Views.
It allows you to hook your code to different events such as "Search is updated", "Search results are loaded", etc)

I think this should solve the problem you see.

#616798

I also think but I do not know how I have to fill the various fields. I have to put my code in a function and indicate the name of the function or the name of the function with brackets, I do not see too much. You would have no screenschot with an example please ?

#616823

Noman
Supporter

Languages: English (English )

Timezone: Asia/Karachi (GMT+05:00)

4.png
3.png
2.png
1.png

Hi Simon,

I am taking over this ticket, here are screenshots.

Thank you

#616841

That works fine, thanks a lot