$(function () {
    $(document).on('click', '.read-more-button:not(.no-js)', function (e) {
        var kjo = $(this);
        var next = '#';
        e.preventDefault();
        $.get($(this).attr('href'), function (data) {
            var template = $("#" + kjo.data('category')).html();
            
            $.each(data.articles, function(k, v){
                var text = Mustache.render(template, v);
                $('#' + kjo.data('category') + '-articles').append(text);
                next = v.next;
            });
            if(data.pagination.next_page){
                $(kjo).attr('href', next + '&faqe=' + data.pagination.next_page);
            } else {
                $(kjo).remove();
            }
        }, 'json').done(function () {
            
        }).fail(function () {
            $(kjo).remove();
        });
    });
});
