Access to .js-File from another .ux-File

Hi there

I have a MainView.ux with a MainView.js included.

In the MainView I’m also including NewsItem.ux (like in the SocialMedia-Sample).

Now I’m trying to get access from the NewsItem.ux to a function that’s in the MainView.js

What need I to do? At the moment, it’s crashing, when NewsItem.ux is calling a function from MainView.js (can’t find it - "Callback not found: … ")

Including the same .js-File maybe could work? But I think thats probably not soo good, if I also want to gain access to same Objects and Lists… ?

Hi! Not 100% clear on what you mean here. Maybe you could post some code to illustrate? Thanks :slight_smile:

Sure, I will try to give a simple sample of what I mean:


    <JavaScript File="parse-1.5.0.min.js" ux:Global="Parse"/>
    <JavaScript File="MainView.js"/>
    <PageControl ux:Name="_nav">
        <Page ux:Name="main_page" Background="#34495e">
            <Button Clicked="{someFunction}"/>
         <Page ux:Name="some_page">
                <StackPanel Alignment="Top">
                    <Each Items="{items}">
                        <NewsItem />

part of NewsItem.ux:

<StackPanel ux:Class="NewsItem" Margin="0,14,0,10">
        <Button Clicked="{someFunction}"/>


function someFunction(){
    console.log("some text");

I hope that’s a bit more clear now.

So, I included the MainView.js in the MainView.ux - and want to get access to a function in the MainView.js from the NewsItem.ux - but that’s not working.

This should “just work”, there must be some details you are not showing that is making it break.

Did you remember to add someFunction to module.exports ?

… that’s it. :confused: I just forget this one function in the module.exports… Thanks. :slight_smile: