我有一个名为getMedia()
的函数,它会触发ajax
调用以获取一些内容。我在顶部还有一些过滤器onclick
我已经将内容网格绑定到了内容网格并获取新内容,但是当文档加载时它会被触发。
$(document).ready(function() {
var numposts = $(".social__board").data('numposts');
$.each(accounts, function(key, value) {
getMedia(".board", key, value, numposts);
});
setGridFilter(".filters", ".board", ".grid-item");
});
然后在同一个文件中我有setGridFilter
函数。
function setGridFilter(filters, board, griditem) {
$(filters + " li").first().addClass("active");
$(document).on("click", $(filters + " li"), function(){
$(griditem).remove();
$(this).addClass('active');
$(this).siblings().removeClass("active");
var source = $(this).data("source");
var numposts = $(board).data('numposts') * 3; // MORE POSTS FOR SINGLE CHANNEL
var username = $(board).attr("data-" + source);
console.log("Source: " + source + "Numposts: " + numposts + "Username" + username);
getMedia(board, source, username, numposts);
});
}