where movieCard is another ux file. movieList is a js observable from mainview.js. Inside MovieCard i tried to use another JS (including the file as follows )
function click is inside movieCards.js and is called inside movieCards.ux not in mainview.ux if i understood correctly what you said. So how am i going to export it on mainview.ux ?
oh, it did not say so. What i ment was that you should have the click function in your mainview.js file, but i think i migth have missunderstood your post, i will try to read it again
maybe you have a test project with this not working i could look at?
Add a console.log at the top to check. You should also remove ux:Global="mainview" from your JavaScript tag.
You are not showing us all your code, so I not able to give you a correct answer, but from what I can see you should include your MovieCards.js in your parent UX file. But that is a bit hard to tell since I don’t know where you use panelVisibility.
var Observable = require('FuseJS/Observable');
var panelVisibility = Observable("Hidden");
var height = Observable("0");
console.log("is it in ?");
function click()
{
console.log(">>>> ???? <<<<<");
if(panelVisibility.value == "Visible")
{
panelVisibility.value = "Hidden";
height.value = "0"
} else {
panelVisibility.value = "Visible"
height.value = "94%"
}
}
module.exports = {
panelVisibility : panelVisibility,
height : height,
click : click
};
if i have it like this the first log that i have inside MovieCards.js is not printed at all. Moreover if i dont use ux:Global=“MainView” the movie cards i have doesn’t take the necessary info from the mainView.js. If i move the
<JavaScript File="MovieCards.js"/>
inside the mainview then mainview.js doesn’t work. Also tried to merge the two js files but with no luck.
If i run the above code it prints but as i said i am losing all the info i have from the mainview.js. Because inside the MovieCards.ux i am using info that i have stored in observables in mainview.js. If i include the ux:Global the info are ok again but when i press the button it doesn’t do anything.
It doesn’t work because you are using ux:Global (that is deprecated). When you create a new <JavaScript> tag you overwrite the datacontext of the previous tag.
You can move your code to mainview.js and check the argument to click(arg) which panel you clicked.