JavaScript function in global scope (window) - which options do I have?

0
Hi all, I have external content embedded in the Mendix application (an embedded widget if you will). This embedded widget has it's own events like (onReady, onSubmit, onClose), the callback functions for these events need to be in the global scope (window). E.g. I want a function, like below to be available in the Global scope, what options do I have to do this? - In the index.html would be an option? But doesn’t seem to be preferable - I tried JavaScript actions, but I don't know how to make the available on global scope - ...? function submit(event) { console.log(event.submission_id) } Thank you!
asked
2 answers
4

Hi Stephan Bruijnis

You can place you java script code in Layout templet so will we available throughout the application.

use javascript snippet.

Thanks. 

answered
0

The answer was to make the function global by adding it to the window, like this:

window.submit=function(event){
 console.log(event.submission_id)
};

 

answered