myEvent.raise doesnot work from sub ux file

Hello
I use UserEvent and call it in the same UX file, it works 100%
but use UserEvent in main.ux and call it in sub ux by javascript will not work

Error: ReferenceError: myEvent is not defined: Name: ReferenceError: myEvent is not defined
Error message: Uncaught ReferenceError: myEvent is not defined
thank you

Please share a complete, minimal reproduction that we could copy-paste and run to see the problem, otherwise it’s impossible to help.

In general, JavaScript has access to ux:Names in its local data context. So if your myEvent is living somewhere up the tree, you will likely need to pass it in to your “sub ux” as a ux:Dependency. There’s an article in docs about Dependencies.

As for a complete, somewhat complex example on UserEvents, see this.