2014-10-21 4 views
1

div에 대한 의견 섹션을 표시하거나 숨기려면 jquery 토글이 있습니다. 그러나 나는 코멘트 섹션 paginating, 어떤 이유로 아약스 요청 표시/숨기기 작업을 중지합니다. 어떤 아이디어 야?Ajax 요청 후 div 표시가 작동하지 않음 - Javascript/Ajax

JQuery와 코드

$('.show-all-comments').click(function() { 
     $(this).parent().next('.comments-box').slideToggle("fast"); //slide following class called .comments-box 
    }); 

    jQuery(function($) { //function for pagination. 
     $('.post-list').on('click', '#pagination a', function(e){ 
      e.preventDefault(); 
      var link = $(this).attr('href'); 
      console.log(link); 
      $('.post-list').fadeOut(200, function(){ 
       $(this).load(link + ' .post-list', function() { 
        var link = $(this).attr('href'); 
        $(this).fadeIn(100); 
       }); 
      }); 
     }) 

HTML 출력 내가 매김을 제거하면이 그것을

감사를 작동 할 수 있도록 페이지의 모든 글보기

<div class="large-5 medium-5 small-12 columns"> 
      <a class="show-all-comments btn-third-priority">See Comments</a> 
     </div> 
<div class="large-7 medium-7 small-12 columns"> 
      <p style="padding-top: 10px; margin-bottom: 4px; font-size:0.9em;">One Response to "Post" 
</div> 

<div class="comments-box">Content</div> 

,

DIM3NSION

답변

0
나는 하나의 오류를 볼

, 즉 귀하의 페이지 매김의 문제이지만, 될 수 있는지 확실하지 않습니다, 당신은

$('.show-all-comments').click(function() { 
      $(this).parent().next('.comments-box').slideToggle("fast"); //slide following class called .comments-box 
     }); 

말을하지만, 이것은 당신이 보여 HTML 출력 작동하지 않습니다. 이 작업을하려면, 당신은 바로 다음 형제를 선택합니다

$('.show-all-comments').click(function() { 
      $(this).parent().siblings('.comments-box').slideToggle("fast"); //slide following class called .comments-box 
     }); 

다음() 함수로 변경해야하고, 셀렉터가 추가되는 경우에는 선택 일치하는 경우에만, 그것이 일치합니다. 문제는 .comments-box가이 DIV 노드가 사이에 끼어 있으므로 언젠가 다음 형제가 아니란 점입니다.

관련 문제