Skip Navigation

[Resolved] Ajax Loaded Paginated Wp-View breaks pagination

The Toolset Community Forum is closed, for technical support questions, please head on to our Toolset Professional Support (for paid clients), with any pre-sale or admin question please contact us here.
This is the community support forum for Types plugin, which is part of Toolset. Toolset is a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients and people who registered for Types community support can post in it.


This topic contains 1 reply, has 2 voices.

Last updated by Caridad 7 years, 5 months ago.

Assigned support staff: Caridad.


When a paginated view is loaded via ajax, pagination does not work because the javascript is run on document ready and the variables needed to initialize the script are loaded through a script echoed via a wp_footer hook.

Working Solution:
For the script to run, wrap the code in a global function and call it on document ready, allowing ajax plugins to execute the pagination script on demand for newly loaded content, possibly taking into account a selector context.

function wpv_pagination(context) {
	context = context || document;

	// Preload images in paginator initially
    jQuery('.wpv-pagination-preload-images', context).css('visibility', 'hidden');
    jQuery('.wpv-pagination-preload-pages', context).each(function(){
        var view_number = jQuery(this).attr('id').substring(16);
        var max_pages = jQuery('#wpv_paged_max-'+view_number, context).val();
        wpv_pagination_preload_pages(view_number, 1, max_pages, false, true);

	// Move the wpv_view_hash, wpv_paged_max and wpv_widget_view_id from the forms as it's only needed during ajax pagination
	jQuery('input[name=wpv_view_hash], input[name=wpv_paged_max], input[name=wpv_widget_view_id]', context).each(function(index) {

For the initializing variables, instead of adding a <script> in the footer to initialize these variables, you should use the following code to initialize them in WP_Views->init() right after declaring the pagination script:

wp_localize_script( 'views-pagination-script', 'wpv_admin_ajax_url', admin_url('admin-ajax.php'));
wp_localize_script( 'views-pagination-script', 'wpv_ajax_pagination_url', $ajax_url );

I hope this fix is incorporated in a near WPViews release.



Dear Ioannis

I was able to reproduce your issue and I forward the information to the developers.

Thank you for a detailed report.


The forum ‘Types Community Support’ is closed to new topics and replies.