jQuery的砌体和Ajax追加项目? [英] jQuery Masonry and Ajax Append Items?
本文介绍了jQuery的砌体和Ajax追加项目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图用一些Ajax和jQuery的砌体插件添加一些项目 - 但由于某些原因,新项目没有得到砌筑应用
I am trying to use some ajax and the jQuery Masonry plugin to add some items - but for some reason the new items aren't getting the masonry applied ?
我用
jQuery.ajax({
type: "POST",
url: ajax_url,
data: ajax_data,
cache: false,
success: function (html) {
if (html.length > 0) {
jQuery("#content").append(html).masonry( 'appended', html, true );
}
});
});
不过其随后追加的项目不具备类=砌体砖
应用,这意味着他们的东西了彻底的定位是什么?
However the items that are appended subsequently don't have the class="masonry-brick"
applied which means that they stuff up completely the positioning ?
推荐答案
也有类似的问题,而是使用以下行(换算为您的code)。很抱歉,我不记得在那里我找到了。
Had a similar problem and instead used the following line (converted for your code). Sorry, I don't recall where I found it.
在你的code替换这样的:
In your code replace this:
jQuery("#content").append(el).masonry( 'appended', el, true );
通过这样的:
jQuery("#content").append(el).masonry( 'reload' );
http://masonry.desandro.com/methods.html
这篇关于jQuery的砌体和Ajax追加项目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文