최근 검색
최근 검색 없음

Trevor Smith
가입한 날짜: 2022년 2월 08일
·
마지막 활동: 2022년 2월 08일
팔로잉
0
팔로워
0
총 활동 수
3
투표
1
가입 플랜
1
활동 개요
배지
문서
게시물
커뮤니티 댓글
문서 댓글
활동 개요
님의 최근 활동 Trevor Smith
Trevor Smith님이 에 댓글을 입력함
Ashleigh,
Thank you so much for this great workaround! I've been looking for a solution to the 30 article limit for some time.
Bruce - are you able to share your complete example? I am also on V1, I was able to get the articles on the second page to show, along with removing the pagination - however, every time it executes, it seems to be overwriting the current article list on the first page. In place of the first-page list, I'm getting '[object HTMLLIElement] ' displayed on the page.
I could technically assign the 'new' list to a different div, but I'd rather append the original div to create one entire list so I can filter through it.
**EDIT - I figured it out - had to change "+=" to just + in this:
the_list = next_page.response.getElementsByClassName("section-tree")[0].innerHTML;
and had to change "=" to "+=" in this:
// Write the new list to the current page.
document.getElementsByClassName("section-tree")[0].innerHTML += the_list;
Here is the full script that now works for me on V1...
// Zendesk Guide section pages without pagination (v2).
// author: Ashleigh Rentz, koresoftware.com
// license: https://mit-license.org/
window.onload = function() {
unpaginatedSections();
};
function unpaginatedSections() {
debugger;
// Only execute this if we're on a paginated section page.
if (document.getElementsByClassName("pagination")[0] == null) return;
// Start with the articles listed on the first page
var the_list = document.getElementsByClassName("pagination-next")[0];
var next_url = the_list.getElementsByTagName("a")[0].getAttribute('href');
// Request the next page
var next_page = new XMLHttpRequest();
next_page.open("GET", next_url);
next_page.responseType = 'document';
next_page.send();
next_page.onload = function() {
// If something went wrong, leave pagination in place.
if (next_page.status !== 200) return;
// Add the articles from this page of results to our list.
the_list = next_page.response.getElementsByClassName("section-tree")[0].innerHTML;
// Check for another page.
try {
var nextlink = next_page.response.getElementsByClassName("pagination-next")[0];
next_url = nextlink.getElementsByTagName("a")[0].getAttribute('href');
}
catch (e) {
// No more pages.
is_finished = true;
}
finally {
if (is_finished) {
// Write the new list to the current page.
document.getElementsByClassName("section-tree")[0].innerHTML += the_list;
// Add a class to allow styling via CSS.
// Remove the pagination controls.
document.getElementsByClassName("pagination")[0].innerHTML = '';
};
};
};
};
Best,
Trevor
댓글 보기 · 2022년 2월 08일에 편집됨 · Trevor Smith
0
팔로워
0
투표 수
0
댓글