How to use utilities scroll to element from menu to home page?
Application Type
Reactive

Hi Everybody

I'm having trouble using the scrolltoelement to make the user be able to click on an item in the menu and go to a certain place within the same page. I'm using events and a switch like decision logic.

Any suggestion?

Solution

Hello,

I think the links are on menu block, and you need to scroll to particular element which belong to a screen,

First we need to pass the value from block to screen, so you have to define a Event on your Menu block, and through which you will pass the value to the screen,  on your block you need to create a screen action that will trigger when a user click on a link then the screen action will be trigger , here you need to do some logic to get the value of  link which is clicked(value will be vary on your logic),

If you want the text of the label you can use JS 

Example

var e = document.getElementById('myName1').getElementsByTagName('p')[0].     
var theText = e.innerHTML;console.log(theText);

// or, in sufficiently-modern browsers

e = document.querySelector('#myName1 p a');
theText = e.innerHTML;console.log( theText );

what ever you will prefer

Then through even pass the Value

Now if your Screen is the Parent of your block then only you will get the value, else check whether you menu block is called on another block, if so then handler will be defined on  the other block which will behave as a parent for the menu block.

Once you get the value 

on your handler compare it with your switch conditions, and use it as described in above comment by @Jozy 

Thanks 

Thanks a lot @Tousif Khan and @jozy.  I made replacement it like you comment and done!

You're Welcome,

 Glad to help you :)

 Kind regards,

Tousif khan


Hi @CARLOS GUIMARÃES,

You can use JS to scroll to a specific element.

Hope it helps.

Hi Carlos,

I hope you are passing the widget id to scrollToElement, if not, then please pass widget id o which you want to scroll.

hope it hepls,

Regards,

Jozy

Solution

Hello,

I think the links are on menu block, and you need to scroll to particular element which belong to a screen,

First we need to pass the value from block to screen, so you have to define a Event on your Menu block, and through which you will pass the value to the screen,  on your block you need to create a screen action that will trigger when a user click on a link then the screen action will be trigger , here you need to do some logic to get the value of  link which is clicked(value will be vary on your logic),

If you want the text of the label you can use JS 

Example

var e = document.getElementById('myName1').getElementsByTagName('p')[0].     
var theText = e.innerHTML;console.log(theText);

// or, in sufficiently-modern browsers

e = document.querySelector('#myName1 p a');
theText = e.innerHTML;console.log( theText );

what ever you will prefer

Then through even pass the Value

Now if your Screen is the Parent of your block then only you will get the value, else check whether you menu block is called on another block, if so then handler will be defined on  the other block which will behave as a parent for the menu block.

Once you get the value 

on your handler compare it with your switch conditions, and use it as described in above comment by @Jozy 

Thanks 

Thanks a lot @Tousif Khan and @jozy.  I made replacement it like you comment and done!

You're Welcome,

 Glad to help you :)

 Kind regards,

Tousif khan


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