<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.isotope/2.2.1/isotope.pkgd.min.js"></script>
<script>
$(document).ready(function() {
var $container = $('.works');
$container.isotope({
itemSelector: '.work'
});
$('#filter a').click(function(){
$('#filter a').removeClass('current');
$(this).addClass('current');
var selector = $(this).attr('data-filter');
var getQuery = 'test2.php?';
getQuery += 'filter='+selector;
$.ajax({
cache:false,
url: getQuery,
success: function($data){$('.works').append($data).isotope( 'appended',$data); console.log(data)}
});
$('.works').isotope({
filter: selector,
animationOptions: {
duration: 1000,
easing: 'easeOutQuart',
queue: false
}
});
return false;
});
});
</script>
<ul id="filter" class="clearfix">
<li><a href="" class="current btn" data-filter="*">Все</a></li>
<li><a href="" class="btn" data-filter=".portfolio">Портфолио</a></li>
<li><a href="" class="btn" data-filter=".cutaway">Визитки</a></li>
<li><a href="" class="btn" data-filter=".corporative">Корпоративные</a></li>
</ul>
<div><a id="append-button" href="#" class="btn">Портфолио</a></div>
<div class="works clearfix" id="movieBox">
<article class="work portfolio">
<p class="number">519</p>
<div>
<img src="images/portfolio/1.jpg" width="300" height="220" />
<h3>1</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</article>
<article class="work cutaway">
<p class="number">592</p>
<div>
<img src="images/cutaway/1.jpg" width="300" height="225" />
<h3>2</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</article>
<article class="work corporative">
<p class="number">593</p>
<div>
<img src="images/corporative/1.jpg" width="300" height="260" />
<h3>3</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
</div>
</article>
</div>
filter: selector,
$('.works').isotope({
filter: "тут сразу задайте класс для фильтра изотопа",
});
$(document).ready(function() {
var $container = $('#movieBox');
var cache = $container.html();
$container.isotope({
itemSelector: '.work'
});
$('#filter a').click(function() {
$('#filter a').removeClass('current');
$(this).addClass('current');
var selector = $(this).attr('data-filter');
$.ajax({
cache: false,
url: 'test2.php?filter=' + selector,
success: function(data) {
// HERE YOU CAN DO SOMETHING WITH YOUR DATA
//Collecting every new isotope in cache
cache += data;
//Making our container clean by destroying the isotope functionality
$container.isotope('destroy');
//Rewriting our new collection of isotopes to our container
$container.html(cache);
//Set new instance of the isotope functionaly in our container using last clicked filter
$container.isotope({
itemSelector: '.work',
filter: selector
});
}
});
$container.isotope({
filter: selector,
animationOptions: {
duration: 1000,
easing: 'easeOutQuart',
queue: false
}
});
return false;
});
});
</script>