App Builder

Index of ContentsExternal Javascript

App Builder doesn't requires that we know Javascript in order to create our apps, but, we can use Javascript if we need for some reason. We can include Javascript files using the app file's manager or we can use Javascript between the StartJS and EndJS actions in our scripts.

If we want to use external Javascript, maybe we need to access to some app stuff. And we can. App Builder exposes some variables into the "window" Javascript object that we can use to access app variables, app functions and app control events.

window.App.Scope & window.App.RootScope

We can use these variables to access app variables and call app user functions, for example:

// Set one of our app variables
window.App.RootScope.MyVar = 'New value';

// Give the content of an app variable
alert(window.App.RootScope.MyVar);

// Call one of our app user function
window.App.Scope.MyFunc();

window.App.[ViewName].Scope

We can use this variable to access app views specific control events. Probably it's not a good idea to call a control event directly. Instead of that, we can prepare the stuff of such event in an app user function, and then call to that function from the control event and, if needed, using the "window.App.Scope" variable. However, if we wanted, we can access control events in this way:

// Call the NewView1 Button1 control Click event
window.App.NewView1.Scope.Button1Click();

// Call the NewView1 Input1 control Change event
window.App.NewView1.Scope.Input1Change();
Take a look at the External app sample included by App Builder! This app sample show us how to access the app stuff from external Javascript code.