Вывод постов из инстаграм на сайте

238
30 ноября 2017, 04:03

Приветствую! На сайте http://isvektor.beget.tech/, выводится посты из инстаграма с помощью Instafeed.js. Вывод вроде реализовал, а вот с установкой кнопки "Загрузить больше" запара. Как ее вообще надо реализовывать? На сайте разработчика плагина, есть такой код, а вот как его использовать не знаю. Посты вывожу так:

$(document).ready(function() {

var userFeed = new Instafeed({
    get: 'user',
    userId: 'userid',
    limit: 7,
    resolution: 'standard_resolution',
    accessToken: 'tokenid',
    sortBy: 'most-recent',
    template: '<div class="rol-lg-2 instaimg"><a href="{{link}}" target="_blank"><img src="{{image}}" alt="{{caption}}" class="img-fluid"/></a></div>',
});

userFeed.run();

});

var loadButton = document.getElementById('load-more');
var feed = new Instafeed({
    // every time we load more, run this function
    after: function() {
        // disable button if no more results to load
        if (!this.hasNext()) {
            loadButton.setAttribute('disabled', 'disabled');
        }
    },
});
// bind the load more button
loadButton.addEventListener('click', function() {
    feed.next();
});
// run our feed!
feed.run();
Answer 1

А если объединить оба метода?

var loadButton = document.getElementById('load-more');
var feed = new Instafeed({
    get: 'user',
    userId: 'userId',
    limit: 7,
    resolution: 'standard_resolution',
    accessToken: 'accessToken',
    sortBy: 'most-recent',
    template: '<div class="rol-lg-2 instaimg"><a href="{{link}}" target="_blank"><img src="{{image}}" alt="{{caption}}" class="img-fluid"/></a></div>',
    // every time we load more, run this function
    after: function() {
        // disable button if no more results to load
        if (!this.hasNext()) {
            loadButton.setAttribute('disabled', 'disabled');
        }
    },
});
// bind the load more button
loadButton.addEventListener('click', function() {
    feed.next();
});
// run our feed!
feed.run();

Скрыл ваши данные, чего и вам советую