Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 同位素布局方法不布局项目_Jquery_Jquery Isotope - Fatal编程技术网

Jquery 同位素布局方法不布局项目

Jquery 同位素布局方法不布局项目,jquery,jquery-isotope,Jquery,Jquery Isotope,在我的项目中,我使用同位素过滤数据库中的所有项目, 但是当没有找到任何项时,它应该从API加载一些项 我有一个函数叫做getapitems,当找不到项时调用这个get, 现在我有一个硬编码的元素来测试它 但问题是,API项不像my db项那样获得布局,它们都显示在彼此的顶部,如下所示: 虽然它应该显示如下项目: 这是用于添加元素的代码 function getAPIitems() { addToIsotope(); } function addToIsotope() { v

在我的项目中,我使用同位素过滤数据库中的所有项目, 但是当没有找到任何项时,它应该从API加载一些项

我有一个函数叫做
getapitems
,当找不到项时调用这个get, 现在我有一个硬编码的元素来测试它

但问题是,API项不像my db项那样获得布局,它们都显示在彼此的顶部,如下所示:

虽然它应该显示如下项目:

这是用于添加元素的代码

function getAPIitems() {
    addToIsotope();
}

function addToIsotope() {
    var elem = '<div class="shop_box     apiItem" style="position: absolute; left: 0px; top: 0px;">' +
        '<a href="ProductDetail.aspx?productID=1">' +
        '<div class="shop_image">' +
        '<img id="MainContent_Items_LabelImage_0" src="productsImages/2155567690287400.png">' +
        '</div>' +
        '<span id="MainContent_Items_new_0" class="new-box">' +
        '<span class="new-label">New</span>' +
        '</span>' +
        '</a>' +
        '<div class="shop_desc">' +
        '<h3>' +
        '<a href="ProductDetail.aspx?productID=1">The North Face® Cat\'s Meow 20° Sleeping Bag</a>' +
        '</h3>' +
        '<p>Three-season mountaineering starts here with a quintessential synthetic-insulated sleeping bag rated to 20°. As part of the Core series, the</p>' +
        '<span class="actual">€  200.00</span>' +
        '<span id="MainContent_Items_reducedfrom_0" class="reducedfrom">€ 205.00</span' +
        '<ul class="buttons">' +
        '<li class="cart">' +
        '<a ng-click="UpdateBasket(product.Id)">To Basket</a>' +
        '</li>' +
        '<li class="shop_btn">' +
        '<a id="MainContent_Items_Read_more_0" href="ProductDetail.aspx?productID=1">Read more</a>' +
        '</li>' +
        '<div class="clear"> </div>' +
        '</ul>' +
        '</div>' +
        '</div>';

    $container.isotope()
        .append(elem)
        .isotope('appended', elem)
        .isotope('layout');

}
函数getapitems(){ addToIsotope(); } 函数addToIsote(){ 变量元素=“”+ '' + '' + '' + '' + '' + 三季登山从这里开始,最经典的合成绝缘睡袋额定角度为20°。作为核心系列的一部分,这款

'+ '€ 200.00' +
“€205.00您是否有与此相关的实时版本或代码笔的链接?我的直接猜测是,当同位素尝试初始化布局时,您的元素没有完成追加。我尝试运行
$container.isoto(“布局”)
在控制台中加载所有内容后,仍然不起作用。需要一个示例或附加代码。您在哪里调用getAPIitems()?