Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6249611
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:16:17+00:00 2026-05-24T13:16:17+00:00

Please see my script here: LIVE EXAMPLE There is a unintelligible behavior which I

  • 0

Please see my script here: LIVE EXAMPLE

There is a unintelligible behavior which I have noticed.

Onload 'All' have 3 option visible – but when you switch to 'logo' and back to 'all' we have 4.

Why? There should be 4 item in the first tab as well.

How does the script works:

  • onload – I have defined that our var filterClass = "all"; is all which means to show ONLY li with 'all' class.
  • when you select something front the top menu – it is taking it’s class and finds li with the same class (‘li’ have multiple classes)
  • on every change we run CreateTabs function which basically check how many ‘li’ we have and make them in tabs (4 on every tab).

Onload Scipt – which controles classes:

$('#portfolio-items li').CreateTabs();   
var filterClass = "all";

$('.portfolio-filter li a').click(function() {


    $('.portfolio-filter > .selected').prop('class', '');
    $(this).parent('li').addClass('selected');

    filterClass = $(this).attr('class');

    $('#portfolio-items li').hide();
    $('#portfolio-items li.' + filterClass).show();
    $('#portfolio-items').CreateTabs(filterClass);

});

CreateTabs Script:

(function($) {

$.fn.CreateTabs = function(filterClass) {

    var CoundNumberOfDivs = $('#portfolio-items li:visible').length;
    $('.pagination li a').hide();
    if (CoundNumberOfDivs <= 4) {
        return false;
    }
    else {
        var num = Math.ceil(CoundNumberOfDivs / 4);
        $('.pagination li a:lt(' + num + ')').show();
        $('#portfolio-items li').hide();
        if (filterClass === undefined) {
            $('#portfolio-items li:lt(4)').show();
        } else {
            $('#portfolio-items li.' + filterClass + ':lt(4)').show();
        }
    }

};
})(jQuery);

Onload script which controles TABS

$('ul.pagination li a').click(function(event) {
    $('ul.pagination li .active').removeClass('active');
    $(this).addClass('active');

    var PI = $('#portfolio-items li' + (filterClass !== undefined) ? '.' + filterClass : '');
    $('#portfolio-items li').hide();


    if ($(this).hasClass('href-1')) {
        PI.slice(0, 4).show();
    }
    else if ($(this).hasClass('href-2')) {

        PI.slice(4, 8).show();
    }
    else if ($(this).hasClass('href-3')) {
        PI.slice(8, 12).show();
    }
    else if ($(this).hasClass('href-4')) {
        PI.slice(12, 16).show();
    }
    else if ($(this).hasClass('href-5')) {
        PI.slice(16, 20).show();
    }
    else if ($(this).hasClass('href-6')) {
        PI.slice(20, 24).show();
    }
    else if ($(this).hasClass('href-7')) {
        PI.slice(24, 28).show();
    }
    else if ($(this).hasClass('href-8')) {
        PI.slice(28, 32).show();
    }
    else if ($(this).hasClass('href-9')) {
        PI.slice(32, 36).show();
    }
    event.preventDefault();
}).filter(':first').click();
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T13:16:18+00:00Added an answer on May 24, 2026 at 1:16 pm

    Looking at the jQuery .slice() documentation:

    The index is once again zero-based; the range extends up to but not including the specified index.

    So, for example:

    if ($(this).hasClass('href-1')) {
        PI.slice(0, 4).show();
    }
    

    should be:

    if ($(this).hasClass('href-1')) {
        PI.slice(0, 5).show();
    }
    

    Edit

    Dennis is absolutely correct, and I cannot count. You were slicing on the wrong thing, due to not being explicit enough with your usage of parentheses:

    $('#portfolio-items li' +  (filterClass !== undefined) ? '.' + filterClass : '' );
    // vs
    $('#portfolio-items li' + ((filterClass !== undefined) ? '.' + filterClass : ''));
    

    This solves a number of bugs in a number of places, most of which exist because there is a disjoint in how you render “pages” when selecting a category, and when selecting a page number.

    • When clicking on a page number (and on page load, due to your .filter(':first').click()), this bug would manifest.

    • But, when clicking on a category, a different logic is invoked — $('#portfolio-items li:lt(4)').show() — which does not exhibit this issue.

    I’d consider a stronger high-level design, where the “state” of the interface is tracked in one place and re-rendered whenever necessary.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Adorner which adornes a Border (please see screenshot below). The MouseDown
Please see the my test site here . The script is written in the
Please see here for a related question . However, char goes to 0xffff (or
everyone. Please see example below. I'd like to supply a string to 'schedule_action' method
I have sql server procedure, please see below. ALTER PROCEDURE [dbo].[uspInsertDelegate] ( @CourseID int,
This question is related to this question yesterday . Please see current jsfiddle here
I have this script which sends an email for users to activate their accounts
(Problem solved, please see the updates) I have some files that have incorrect filenames
Please see the the following http://valogiannis.com/recent/ .I have a webpage and when user click
Please see code below. The destructors are never called. Anyone know why and how

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.