我有我正在使用 XML 和 jQuery 加载的对象,并试图连接到 Isotope,但似乎这是不行的。这可能吗?我尝试了许多不同的解决方案,但似乎找不到一个有效的解决方案。这就是我所拥有的。我在同位素中尝试了一个回调函数,但仍然没有运气。我在我的班级中使用 XML 调用,结果在萤火虫中是这样的:item yellow、item red、item blue等。
var $container = $('#container');
var $checkboxes = $('#filters a');
$container.isotope({
itemSelector: '.item',
transformsEnabled: false,
animationOptions: {
duration: 4000,
easing: 'easeInOutQuad',
queue: false,
complete: complete()
}
});
function complete(){
$.get('sites.xml', function (d) {
$(d).find('site').each(function () {
// var id = $(this).attr('id');
var imageUrl = $(this).find('imgurl').text();
var title = $(this).find('title').text();
var url = $(this).find('url').text();
var brief = $(this).find('brief').text();
var long = $(this).find('long').text();
var classa = $(this).find('_class').text();
$('<div class="' + classa + '"></div>').html('<a href="' + url + '">
<img src="' + imageUrl + '" class="thumbnail" />' + '<h1>' + title + '</h1>
</a>').appendTo('#container');
});
});
}