Reach same javascript from outside of page

I’m trying to change an attribute through javascript. It works fine from another page but when I’m trying to reach it from the main view which has no page class, it won’t work at all. If I import the javascript in the main view too, it changes the value but it seems to be a different instance. Why is there a difference between another page and a file without a page class?

Is there any better solution? The problem is that I have a mapview and a sidebar menu and the nativeviewhost is causing the map to cover the sidebar.

Hi Ninni,

we usually prefer seeing some code along with conceptual questions, because otherwise it’s nearly impossible to understand what have you tried to do and how you have done that.

The first part of your story hints that you might be doing something wrong with your JavaScript files. You see, in Fuse there’s viewmodel JS files - it’s those you refer directly to from UX markup, like so:

<JavaScript File="MainView.js" />

and then there’s the model JS files - it’s those you refer to from other JavaScript files, like so:

var someLibrary = require("Modules/someLibrary.js");

Now the thing you need to keep in mind is that you may not include model JS files in UX, and you may not require viewmodel JS files in other JS files. If you want to understand why, you should spend some time here, then here and then of course here.

As for the root problem, about which you’ve only written one vague sentence; there is this Social media screen example that stores the sidebar state in a component-local JavaScript variable. That should be a good starting point for what you’re trying to do.