ajax - 将 Ajax 与同位素结合使用
问题描述
我正在尝试将项目附加到基于同位素的 div,并且这些项目正在被附加,但附加的项目没有采用 Css(即它们放错了位置)。以下是我的 html & ajax 函数:
div class="main_isotop" id="container"
var grid = $('.main_isotop').isotope({
itemSelector: '.item',
layoutMode: 'masonry'
});
$.ajax({
url: '/loadmoremedia',
type: 'GET',
datatype: 'html',
data: {
} },
success: function (result) {
//var $items = result;
$('#lastPhotoId').remove();
//$('.main_isotop').append(result);
grid.append(result)
// add and lay out newly appended elements
.isotope('appended', result);
processing = false;
},
error: function (result) {
alert("Failed");
}
});
谁能指出缺少什么?欢迎修改。
解决方案
Isotope 有很多方法可以在使用 ajax 等动态添加新内容后计算布局。
你可以试试这样的
$container.isotope('insert', $items)
或者
$container.append( $html );
$container.isotope( 'appended', $html );
一切顺利。:-)
推荐阅读
- python - 在 Microsoft 认知面部 API 中创建人员组人员时出错
- jquery - 当我单击编辑时模态消失并且 id 也没有传递给控制器
- sql - 将SqlServer表数据加载到csv文件的Shell脚本
- c++ - 动态分配包含要动态分配的向量的向量
- python - 如何递归地创建元组列表?
- google-apps-script - 将 Google Apps 脚本项目切换到 V8 运行时时的范围问题
- c++ - 为什么 std::size 的结果不是编译时间或不是 size_t?
- java - 循环遍历 ArrayList
- android - 如何在 MediaMuxer android 上更改分辨率
- redis - 如何为 CKAN (dockerized) 配置 ckanext-archiver 插件以使其工作?