84
Views
6
Comments
Solved
Unable to scroll to div on hand of Id (React)
Application Type
Reactive
Service Studio Version
11.10.15 (Build 40206)

I'm trying to scroll to the bottom of a div which contains a list messages.


var element = document.getElementById("Cntr_messages");

element.scrollTop = element.scrollHeight;




as expected the name of the Div is Cntr_messages. 

I noticed since i'm using a webblock that the divs id gets a prefix  which is #b23-Cntr_Messages in this case.


 i tried implementing the JS using the prefix and Div id and only the div ID. neither of these options work.

i would greatly appreciate any tips or tricks you guys could provide.


Yours, Jan

 

2018-10-29 08-31-03
João Marques
 
MVP
Solution

Hi Jan,


I would use the ScrollToElement action from OutSystemsUI:


Kind Regards,
João

2026-02-09 13-49-18
Jan-Wilfried Van der Plaats

Thanks for the quick reply!

i tried implementing your second suggestion and got this error.


2020-01-08 08-43-00
Rahul Kumar

Hi Jan, 

You are getting this error because you are running some Javascript too early. JS is running but DOM is yet to be loaded. Place the JS at the bottom of the page. 

Inspect the page in the browser and check the error at the console that would help you to find the cause. 


Regards,

Rahul

2024-01-18 12-42-28
Bogdan Boglea

Hey Jan,


You could pass as input parameter to your JavaScript code the container id 

That is available in any client action that you might be using.


Regards,
Bogdan

2018-10-29 08-31-03
João Marques
 
MVP
Solution

Hi Jan,


I would use the ScrollToElement action from OutSystemsUI:


Kind Regards,
João

2026-02-09 13-49-18
Jan-Wilfried Van der Plaats

Thanks for the quick reply!

i tried implementing your second suggestion and got this error.


2020-01-08 08-43-00
Rahul Kumar

Hi Jan, 

You are getting this error because you are running some Javascript too early. JS is running but DOM is yet to be loaded. Place the JS at the bottom of the page. 

Inspect the page in the browser and check the error at the console that would help you to find the cause. 


Regards,

Rahul

2024-01-31 05-29-41
Akshay Deshpande

Hello jan,

your are getting that error because you container id may be in closed in the if condition of output 

if OutSystems checking that container that run time its may be getting in true but as programmatically was not there

better put the container without if condition or create new container below if and pass the id of that for the scrolling purpose

Thanks and Regards,

Akshay Deshpande

2024-01-31 05-29-41
Akshay Deshpande

Above post related to this reply..(clarification)

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.