2012-04-03 4 views
0

이것은 이전 게시물의 후속 조치입니다. 이제 다른 코드를 사용하십시오.로드 할 게시물이 더 이상 없을 때 "더로드하십시오"링크를 숨기기

나는이 작업을하고, 원하는 모든 페이지를로드합니다 (previous post 참조). 나는 9 페이지 (표준 WP 아카이브에서 클릭에 대해 "앵커"로 next_posts_link를 사용합니다.)

9 페이지가로드 될 때 "로드 더"를 클릭하면 페이지 9가 계속로드됩니다. 중지하고 "부하에게 더 많은"링크를 숨 깁니다. 어떤 도움이 많이 감사합니다.

jQuery(document).ready(function($) { 
var $content = '#upplevelser'; 
var $nav_wrap = '.navigation'; 
var $anchor = '.navigation .nav-previous a'; 
var $text = 'Load More'; 
var $next_href = $($anchor).attr('href'); // Get URL for the next set of posts 
$($nav_wrap).html('<a id="nav-below" href="' + $next_href + '">' + $text + '</a>'); 
$('#nav-below a').click(function(e) { 
    e.preventDefault(); 

if(jQuery(this).attr("href") == "") { 
    alert('I am empty href value'); 
    } 

    $.get($(this).attr('href'), '', function(data) { 
    var $timestamp = new Date().getTime(); 
    var $new_content = $($content, data).wrapInner('<div class="more-articles-here" id="rtz-' + $timestamp + '" />').html(); // Grab just the content 
    $next_href = $($anchor, data).attr('href'); // Get the new href 
    $($nav_wrap).before($new_content); // Append the new content 
    $('#rtz-' + $timestamp).hide().fadeIn('slow'); // Animate load 
    $('#nav-below a').attr('href', $next_href); // Change the next URL 
    $('.more-articles-here ' + $nav_wrap).remove(); // Remove the original navigation 

    }); 
}); 
}); 

답변

0

을 나는 귀하의 요구 사항과 내 로컬 호스트 설치에 대한 자사의 벌금에 맞게 코드를 조금 수정했습니다 .. 여기

입니다 사용 된 중고품입니다.

jQuery(document).ready(function($) { 
var $content = '#upplevelser'; 
var $nav_wrap = '.navigation'; 
var $anchor = '.navigation .nav-previous a'; 
var $text = 'Load More'; 
var $next_href = $($anchor).attr('href'); // Get URL for the next set of posts 
$($nav_wrap).html('<a id="nav-below" href="' + $next_href + '">' + $text + '</a>'); 
$('#nav-below a').click(function(e) { 
    e.preventDefault(); 

if(jQuery(this).attr("href") == "") { 
    alert('I am empty href value'); 
    } 

    $.get($(this).attr('href'), '', function(data) { 
    var $timestamp = new Date().getTime(); 
    var $new_content = $($content, data).wrapInner('<div class="more-articles-here" id="rtz-' + $timestamp + '" />').html(); // Grab just the content 
    $next_href = $($anchor, data).attr('href'); // Get the new href 
    $($nav_wrap).before($new_content); // Append the new content 
    $('#rtz-' + $timestamp).hide().fadeIn('slow'); // Animate load 
    $('#nav-below a').attr('href', $next_href); // Change the next URL 
    $('.more-articles-here .navigation:last').remove(); // Remove the original navigation 

    }); 
}); 
}); 

호프가 너에게 잘 맞을 것입니다 ....

관련 문제