The CreatorCon Call for Content is officially open! Get started here.

Scroll position for modal window in service portal

David Pichard
Mega Guru

Hello all. So in my service portal I have set up the Top Rated Knowledge widget to open it's links in a modal window. This works all well and good but the knowledge articles are fairly lengthy and open up in the center of the article such that you have to scroll to the top of the article each time you open one. I have tried the standard javascript window.scrollTo(x,y) flavors of solving this problem but no luv. Any ideas on how to force modal windows to open automatically scrolled to the top of the article?

Much thanks,

David

2 REPLIES 2

meia_ahaesy
Mega Expert

From my first guess there are two options (you may have already tried):



1. Add an empty anchor tag in the top of all knowledge articles, and add the #anchor link to the url of the modal window


2. Find out a consistent ID of your knowledge article container, and do a DOM / jQuery scrollTop on that.


zineberrada
Tera Contributor

Hello, 

I used the second option, i have already and id = popUp in my HTML CODE, but this didnt work.

var conteneur = $("#popUp");
$scope.btnModifier = function() {
$(".fullscreen-container-debrief").fadeTo(200, 1);
// Vérifiez si l'élément du conteneur existe
if (conteneur.length) {
// Effectuez un défilement vers le haut de l'élément du conteneur
$("html, body").animate({
scrollTop: conteneur.offset().top
}, 200);

 

Any advice please ?

 

Thank you so much