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

  • Home
  • SEARCH
  • 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 8597705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T00:58:23+00:00 2026-06-12T00:58:23+00:00

I am creating pagination using Codeigniter, and I want to add ajax functionality. JS

  • 0

I am creating pagination using Codeigniter, and I want to add ajax functionality. JS is working when pagination link is clicked first time. When it is clicked for the second time JS doesn’t work and pagination is working via PHP controller (this part is working without any problem). This is JS code:

var pag = $('#pagination a');

    pag.on('click', function(e){
        var pagination =
            {
            target : $(this).attr('href') + ' .mali_oglasi',    
            content : $('.mali_oglasi'),
            container: $('.mali_oglasi_wrapper')
            };

            pagination.content.animate({'opacity':0, scrollTop: 0}, 400, function(){
                pagination.container.load(pagination.target, function(){
                    pagination.content.animate({'opacity':1}, 400);
                });                
            });            
        e.preventDefault(); 
    });  

Also scrollTop doesn’t work. What am I doing wrong?

  • 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-06-12T00:58:24+00:00Added an answer on June 12, 2026 at 12:58 am

    Probably that’s because your DOM gets manipulated everytime, and hence the handler for the click event is lost.

    try this way :

    $('body').on('click', '#pagination a', function(e) {
        var pagination =
        {
            target : $(this).attr('href') + ' .mali_oglasi',    
            content : $('.mali_oglasi'),
            container: $('.mali_oglasi_wrapper')
        };
    
        pagination.content.animate({
            'opacity':0, 
            scrollTop: 0
        }, 400, function(){
            pagination.container.load(pagination.target, function(){
                pagination.content.animate({
                    'opacity':1
                }, 400);
            });                
        });            
        e.preventDefault(); 
    });
    

    this will ensure rebinding the click event on each DOM manipulation

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

Sidebar

Related Questions

Creating a simple RPG game, first time using XNA. Trying to get my character
I am creating MVC3 Site and using pagination (using PagedList;) in that to display
I'm having some problems with creating pagination with a HABTM relationship. First, the tables
I am trying detect when a textarea becomes full for creating pagination effect. Using
Hey, i am currently creating a pagination script using php and jquery and for
I am creating a pagination script and I need to get the first and
So i'm creating a pagination system for a blog-like system. I already have the
I'm creating a web app using PHP and PostgreSQL. Database are too big and
I'm Creating a website for online reading stories using grails and i'm facing a
I created a google maps store locator and im using a jquery pagination to

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.