2013-02-15 2 views
2

저는 웹 사이트에서 일하고 있습니다. 이제는 jQuery 동위 원소에 붙어 있습니다. jquery 동위 원소를 사용하여 div를 필터링하지만 어떻게 든 작동하지 않습니다.필터링을위한 jQuery 동위 원소

내 HTML :

<center><a href="" class="filter" rel="all">show all</a> | <a href="" class="filter" rel="green">green</a> | <a href="" class="filter" rel="blue">blue</a> | <a href="" class="filter" rel="pink">pink</a></center> 
<br> 
<div class="wrap"> 
    <div class="box green"></div> 
    <div class="box blue"></div> 
    <div class="box pink"></div> 
    <div class="box blue"></div> 
    <div class="box pink"></div> 
    <div class="box green"></div> 
    <div class="box pink"></div> 
    <div class="box green"></div> 
    <div class="box blue"></div> 

    <div class="clear"></div> 
</div> 

내 CSS :

.wrap{ 
    margin: auto; 
    width: 660px; 
    background: #ccc; 
} 
.clear{ 
    clear: both; 
} 
.box{ 
    float: left; 
    width: 200px; 
    height: 200px; 
    margin: 10px 10px; 
} 
.green{ 
    background: green; 
} 
.blue{ 
    background: blue; 
} 
.pink{ 
    background: pink; 
} 

내 자바 스크립트 :

$(document).ready(function() { 
    $('.wrap').isotope({ 
     itemSelector: '.box' 
    }); 

    $('a.filter').click(function() { 
     var to_filter = $(this).attr('rel'); 
     if(to_filter == 'all') { 
      $('.box').fadeIn(); 
     } else { 
      $('.box').each(function() { 
       if($(this).hasClass(to_filter)) { 
        $(this).fadeIn(); 
       } else { 
        $(this).fadeOut(); 
       } 
      }); 
     } 
     return false; 
    }); 
}); 

또는이 링크를 볼 수 있습니다 http://jsfiddle.net/wPdXF/

내 정확한 문제 : 필터 링크를 클릭 한 후가 , div의이

사람이 제발 도움이 될 수 있습니다 애니메이션/셔플하지 않는 이유는 무엇입니까? 당신은 jQuery의 숨기기에 내장 된 사용하고 있기 때문에 당신이로 실행하고있는 (곳 "필터"항목 있지만 위치를 변경하거나 재배치 애니메이션을하지 않습니다) 내 나쁜 영어

+0

을가 예상 작품으로 – reinder

+0

@reinder을? 아니오, 절대적으로 ......... 답장을 보내 주셔서 감사합니다 : D – user2074851

+0

그러면 문제를 더 잘 설명해야합니다. jsfiddle을 열고 "녹색"을 누르면 녹색 상자 만 표시됩니다. 다른 모든 색상과 동일하고 "모두 표시"는 모든 상자를 보여줍니다. 무엇을 기대합니까? – reinder

답변

2

문제에 대한 유감

입니다/동위 원소 대신에 필터링 메커니즘이 내장되어 있습니다.

$(document).ready(function() { 
$('.wrap').isotope(); 

$('a.filter').click(function() { 
    var to_filter = $(this).attr('rel'); 
    if(to_filter == 'all') { 
     $('.wrap').isotope({filter: '.box'}); 
    } else { 
     $('.wrap').isotope({filter: '.'+to_filter}); 
    } 

}); 
}); 

근무 바이올린 :. http://jsfiddle.net/yDPxK/1/

당신이해야 할 것은 필터 (당신이 당신의 rel 특성에서 일치하고 jQuery의 기본 fadeIn를 사용하여 클래스 이름은/페이드 아웃 그냥 변경됩니다와 동위 원소를 제공하는 그들의 디스플레이 속성 값은 DOM에서의 위치를 ​​변경하지

필터링 문서 :. 당신의 JSFiddle에서 http://isotope.metafizzy.co/docs/filtering.html

+0

나는 이미 필터 옵션을 사용하고 있지만 행운이 없다. 여전히 애니메이션/셔플이 없다. – user2074851

+0

좋아, 내가 바이올린을 치고 내가 작동하도록 할 수 있는지 알아 보겠다. 맞춤 레이아웃 모드 중 하나를 사용하고 있습니까? 벽돌이나 중심이 가장 많이 사용됩니다. –

+0

아니요, 레이아웃 모드를 사용하고 있지 않습니다 .... 도움을 주셔서 감사합니다. D – user2074851