Javascript wookmark modification和li并排并在一起
我正在为我的项目使用wookmark插件,当V滚动到底部时,我需要加载更多项目。 插件url: 我使用的滚动功能:Javascript wookmark modification和li并排并在一起,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我正在为我的项目使用wookmark插件,当V滚动到底部时,我需要加载更多项目。 插件url: 我使用的滚动功能: function _scroll() { var v = false; $(document).scroll(function(e) { var t = document.height - (window.pageYOffset + window.innerHeight); if ((t <= 20) && (
function _scroll() {
var v = false;
$(document).scroll(function(e) {
var t = document.height - (window.pageYOffset + window.innerHeight);
if ((t <= 20) && ( !v)) {
v = true;
$.ajax({ type:"POST",
data: {type:$("#type").val(),id:$("#pid").val(),lid:$("#lid").val()},
async:true,
cache:false,
url:"fetchMore.php?v=18",
success: function(d) {
var t = d.split('{@}');
if (parseInt($("#lid").val()) != t[1]) {
$("#tiles").append(t[0]);
$("#lid").val(t[1]);
applyLayout();
}
v = false;
} });
}
});
}
最后,我的选项和排序功能:
function comparatorId(a, b) {
return $(a).attr("id") > $(b).attr("id") ? -1 : 1;
}
function _Animate() {
$('#tiles').imagesLoaded(function() {
options = {
autoResize: true,
container: $('#main'),
offset: 2,
itemWidth: 210,
comparator: comparatorId,
direction: 'right',
fillEmptySpace: false
};
$handler = $('#tiles li');
$handler.wookmark(options);
});
}
问题是:
当我要加载更多项时,这些项会随机重新排序,就像没有comparatorId函数一样。。
有什么解决办法吗?
如果没有解决办法。。
我怎样才能做一个ul li标签这样的布局?
我可以把它们并排放在一起,但我想让它们并排在一起,互相压着我已经解决了这个问题。。
只需为li添加data id=“{id}”标记并删除所有类
function comparatorId(a, b) {
return $(a).attr("id") > $(b).attr("id") ? -1 : 1;
}
function _Animate() {
$('#tiles').imagesLoaded(function() {
options = {
autoResize: true,
container: $('#main'),
offset: 2,
itemWidth: 210,
comparator: comparatorId,
direction: 'right',
fillEmptySpace: false
};
$handler = $('#tiles li');
$handler.wookmark(options);
});
}