Jump to content

Jquery Load() And Pagination


roundcorners
 Share

Recommended Posts

Hello, I am having difficulty trying to understand what is not working and it is stopping me from discovering a solution to this problem.I am using the hijax technique.On click I am calling a jquery load method and passing it a reference to a section of a page I wish to load into the current page.This also loads links, pagination if you will. I don't want to display each link on the page, so I have put the links within the section to be loaded.So the first time the page loads and I click the 'next topic' link, the method works as intended, but when I click a link from the newly loaded section a new page is loaded. Can anyone help me to understand what is happening so I can figure out how to fix it?Any help appreciated thank you.Javascript below:function updatePage(url){ var page = jQuery('#paginate'); page.addClass('loader'); page.fadeTo(100, 0.5); page.load(url, function(){ page.fadeTo(100, 1); page.removeClass('loader'); });}jQuery(document).ready(function() { jQuery('.pagination a').click(function(event){ var url = this.href+' #paginate'; updatePage(url); event.preventDefault(); });});//SNIPPET OF HTML <div id="centreColumn"> <h2>Tools & techniques</h2> <div id="paginate"> <div class="pagination"><a class="left" href="index.php" title="back to Tools & techniques">Tools & techniques</a><a class="right" href="page2.php" title="Validation">Validation > ></a></div> <h3>Cross-browser compatibility</h3> <p>Ever visited a site with one browser,</p>[/color][/color]

Link to comment
Share on other sites

Hi, I figured it out, it's pretty straight forward really.function updatePage(url){ var page = jQuery('#paginate'); page.addClass('loader'); page.fadeTo(100, 0.5); page.load(url, function(){ page.fadeTo(100, 1); page.removeClass('loader'); getClick(); });}function getClick(){ jQuery('.pagination a').click(function(event){ var url = this.href+' #paginate'; updatePage(url); event.preventDefault(); });}jQuery(document).ready(function() { getClick();});

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...