Hi There,


Developing on OutSystems 11.7.6 and talking about a Mobile application. 

I have a Floating action with some floating items on my screen. When clicking on one of the floating icons ("Aantekening toevoegen" with the comment icon as you can see in the latest screenshot) I am calling some JavaScript to scroll to a part of my screen. But I seem to have a problem with it. When the container is inside the screen this functionallity is working perfectly, but when trying to call a div that's inside a webblock I seem to get an error (Cannot read property "scrollIntoView of null"). As you can see in one of the screenshots below I am doing the JavaScript call on the OrderDetail screen and the div I am trying to reach is inside the NotesBlock. Is there a way to get this to work? Thanks!




Solution

Hi Bart,

I can't really tell from your screenshots, but I think you are passing the name of the div's to the javascript to scroll to.  That's not really safe to do, even if on screens the id and name happen to be the same on mobile.  I don't think there is any guarantee that this will always be the case in future releases, so the only safe way is to refer to things by their id.  

And in the case of blocks, we already have an example where the name = id idea doesn't hold up.

So of course this leaves you with the added task of letting the screen now the id of the div on the block.  See attached oml for one possibility, where the block on ready sends back the id to the parent screen with an event. 

You can see on my demo screen that indeed block id's are not the same as their name, and that using the name on block divs is the only thing at the moment that doesn't work.

This is easy enough if we're talking about one block with one div, don't know how well this scales when you have divs all over the place where you have to keep track of.  But I think your solution with hardcoding the name of divs would be a challenge as well to keep track of, so not that different there.


Good luck,

Dorine

Solution

Dorine Boudry wrote:

Hi Bart,

I can't really tell from your screenshots, but I think you are passing the name of the div's to the javascript to scroll to.  That's not really safe to do, even if on screens the id and name happen to be the same on mobile.  I don't think there is any guarantee that this will always be the case in future releases, so the only safe way is to refer to things by their id.  

And in the case of blocks, we already have an example where the name = id idea doesn't hold up.

So of course this leaves you with the added task of letting the screen now the id of the div on the block.  See attached oml for one possibility, where the block on ready sends back the id to the parent screen with an event. 

You can see on my demo screen that indeed block id's are not the same as their name, and that using the name on block divs is the only thing at the moment that doesn't work.

This is easy enough if we're talking about one block with one div, don't know how well this scales when you have divs all over the place where you have to keep track of.  But I think your solution with hardcoding the name of divs would be a challenge as well to keep track of, so not that different there.


Good luck,

Dorine

Hi Dorine,


Thanks for your reply. I think I know what is going wrong now. With your solution I can make it to work. Thanks!