Skip to:
Content

BuddyPress.org

Changeset 10379


Ignore:
Timestamp:
11/25/2015 09:27:19 PM (4 years ago)
Author:
r-a-y
Message:

JS: Fix an issue with parsing the page number when clicking on a pagination link.

Previously, when a paginated link is clicked, we grabbed the page number
from the URL. This isn't great as the URL is unreliable to parse the page
number (see #6189).

This commit partially reverts r7946 to use the older page number parsing,
but with some logic to properly parse numbers.

See #6745 (trunk).

Anti-props r-a-y.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/bp-templates/bp-legacy/js/buddypress.js

    r10378 r10379  
    946946            el,
    947947            css_id, object, search_terms, pagination_id, template,
    948             url_parameters, page_number,
     948            page_number,
    949949            $gm_search,
    950950            caller;
     
    971971            template = null;
    972972
    973             url_parameters = target.attr('href').split( '&' );
    974             // The page number is the first parameter.
    975             page_number = url_parameters[0].split( '=' );
    976             page_number = page_number[1];
    977 
    978973            // Search terms
    979974            if ( jq('div.dir-search input').length ) {
     
    985980                    search_terms = search_terms.val();
    986981                }
     982            }
     983
     984            // Page number
     985            if ( jq(target).hasClass('next') || jq(target).hasClass('prev') ) {
     986                page_number = jq('.pagination span.current').html();
     987            } else {
     988                page_number = jq(target).html();
     989            }
     990
     991            // Remove any non-numeric characters from page number text (commas, etc.)
     992            page_number = Number( page_number.replace(/\D/g,'') );
     993
     994            if ( jq(target).hasClass('next') ) {
     995                page_number++;
     996            } else if ( jq(target).hasClass('prev') ) {
     997                page_number--;
    987998            }
    988999
Note: See TracChangeset for help on using the changeset viewer.