I have a page rendered with jQuery isotope plugin in this way:
var $container = $('.mydiv'),
colWidth = function () {
var w = $container.width(),
columnNum = 1,
columnWidth = 0;
if (w > 800) {
columnNum = 3;
} else if (w > 600) {
columnNum = 2;
} else if (w > 350) {
columnNum = 2;
} else if (w > 250) {
columnNum = 1;
}
columnWidth = Math.floor(w/columnNum);
$container.find('.element-item').each(function() {
var $item = $(this),
multiplier_w = $item.attr('class').match(/item-w(\d)/)
$item.css({
'margin-bottom': '30px'
});
});
return columnWidth;
},
isotope = function () {
$container.isotope({
animationEngine : 'jquery',
resizable: false,
transformsEnabled: false,
transitionDuration: animationspeed,
itemSelector: '.element-item',
masonry: {
columnWidth: colWidth(),
gutterWidth: 5
},
getSortData: {
name: '.name',
cashable: '.cash',
number: '.number parseFloat',
wr: '.wr parseFloat',
bonus: '.bonus parseFloat',
category: '[data-category]',
country: '[data-country]',
filter: '[data-filter]',
weight: function( itemElem ) {
var weight = $( itemElem ).find('.weight').text();
return parseFloat( weight.replace( /[\(\)]/g, '') );
}
}
}).css({'text-align':'center'});
};
isotope();
$(window).resize(isotope);
Now, I would like to filter the container "mydiv" using an ajax call on a select group:
<select class="form-control input-sm" id="filters-select" data-filter-group="group-three"><option value="">All</option><option value=".option-one">Option One</option><option value=".option-two">Option Two</option><option value=".option-three">Option Three</option></select>
I'm calling ajax in this way:
$('#filters-select').change(function(){
var getQuery = 'http://www.example.com/my-list/search-results/?cat8';
getQuery += '&opt='+this.value.split('.').join("");
$.ajax({
url: getQuery,
success: function(newElementsAjax){$container.isotope('insert', newElementsAjax); isotope();}
});
});
Ajax get success but the container is not updated, filtered, sorted...
Where is my fault, please?
Thanks to all!