私はこのコードを無限にページを四角形上に読み込むために使用しています。私の問題は、私が自分のURLに設定したフィルタリングをリロードすることができないということです。私のコレクション内の変数、あるいはurlやcategoryFilterさえも見ることはできないようです。私は.varディレクティブを使用しようとしましたが、遅延ロードされたアイテムはその前に定義されたものの範囲を見ることができません。私はアイデアが不足しているので、ここで助けてください!四角形上の無限スクロールカテゴリフィルタを取得
編集:私はそれ以来、答えを見つけましたが、別の質問がありました。
私はwindow.location.pathnameの代わりにwindow.location.hrefを使用して、最終的にそのようにパラメータを取得することができました。 IE11ではこれが動作しないので、今私はこれを検索しなければなりません。
<script>
function infiniteScroll(parent, post) {
// Set some variables. We'll use all these later.
var postIndex = 1,
execute = true,
stuffBottom = Y.one(parent).get('clientHeight') + Y.one(parent).getY(),
urlQuery = window.location.pathname,
postNumber = Static.SQUARESPACE_CONTEXT.collection.itemCount,
presentNumber = Y.all(post).size();
Y.on('scroll', function() {
if (presentNumber >= postNumber && execute === true) {
Y.one(parent).append('<h1>There are no more posts.</h1>')
execute = false;
} else {
// A few more variables.
var spaceHeight = document.documentElement.clientHeight + window.scrollY,
next = false;
/*
This if statement measures if the distance from
the top of the page to the bottom of the content
is less than the scrollY position. If it is,
it's sets next to true.
*/
if (stuffBottom < spaceHeight && execute === true) {
next = true;
}
if (next === true) {
/*
Immediately set execute back to false.
This prevents the scroll listener from
firing too often.
*/
execute = false;
// Increment the post index.
postIndex++;
// Make the Ajax request.
Y.io(urlQuery + '?page=' + postIndex, {
on: {
success: function (x, o) {
try {
d = Y.DOM.create(o.responseText);
} catch (e) {
console.log("JSON Parse failed!");
return;
}
// Append the contents of the next page to this page.
Y.one(parent).append(Y.Selector.query(parent, d, true).innerHTML);
// Reset some variables.
stuffBottom = Y.one(parent).get('clientHeight') + Y.one(parent).getY();
presentNumber = Y.all(post).size();
execute = true;
}
}
});
}
}
});
}
// Call the function on domready.
Y.use('node', function() {
Y.on('domready', function() {
infiniteScroll('#content','.lazy-post');
});
});
</script>