Navigate to bottom

  

Hi,

     I have a chat screen in my application. I have used shoutsystems code for the chat. Whenever the user comes to this screen I want the user to see the last chat. I have used a javascript to navigate the user to the bottom of the screen. But there is an error in javascript. 

     Can anyone help me?

     I have placed an HTML element in my screen.PFA.

     Then I have used a javascript in the onready to navigate the user to the bottom of the page. But it throws an error  "$ not defined".

This is the javascript used

$("#" + $parameters.Anchorname).get(0).scrollIntoView({behavior:'smooth'});


Thanks,

Gowtham

Solution

Hello Gowtham,

By the use of the $parameters I am assuming you're working with a MOBILE app, right?

Without seeing the error (that you forgot to put here), my first guess is that you are using JQuery, without actually loading the library (that is discouraged anyway). Mobile applications do not come with jQuery like web applications.


You can use this approach: 

document.getElementById($parameters.anchorName).scrollIntoView();


Hope this helps.
Cheers.

Solution

Hi Jauch,

     Thaks for your reply. It's working.

Hey Gowtham,


Please add the Jquery dependency from the Mobile Pattern, It will work for your previous code.

Hope this will be useful for you in future

Thanks,

Keerthi.

Keerthi Vasan wrote:

Hey Gowtham,


Please add the Jquery dependency from the Mobile Pattern, It will work for your previous code.

Hope this will be useful for you in future

Thanks,

Keerthi.

Hello Keerthi,

Add JQuery (and other libraries), while sometimes is unavoidable, is considered bad practice, as it will impact nagatively in the app performace. 

In this case, use (whenever possible) simple JavaScript or OutSystems logic.

Cheers.


Gowtham wrote:

Hi Jauch,

     Thaks for your reply. It's working.

Hello Gowthan,

If so, please, consider marking my answer as the Solution. This will help others when looking for answers for the same questions.

Happy programming :)

Cheers.


Hi!


By the way, How can I do that in web apps? 

Thanks for your help!


Best regards,

Ricardo

Ricardo Pereira wrote:

Hi!


By the way, How can I do that in web apps? 

Thanks for your help!


Best regards,

Ricardo

Hey Ricardo,


Sorry for the delay, Please use the following component for web application

Scroll


Thanks,

Keerthi.

Thank you Keerthi!


I'll try that and later I give you the feedback! :)


Best regards,

Ricardo