JavaScript namespace problem

Hello all members.

I have a web-wrapper and the wrapper has a javascriptnamespace=“VeryBigForm”. Everything is working fine. Functions are working properly, doing what they are suppose to do. However, upon click on another control, I want to trigger a JavaScript function on my wrapper (that is working if called right after component is shown). Now. How do I call a function from that namespace.
I have tried:

  1. ExecuteJavascript(“XojoCustom.example.VeryBigForm.LoadValues()”) - this is NOT working
  2. ExecuteJavascript(“XojoCustom.VeryBigForm.LoadValues()”) - also, not working
  3. ExecuteJavascript(“XojoCustom.webextrenal.VeryBigForm.LoadValues()”) - this is NOT working, webextrenal is project name

My script goes like this:

function LoadValues()
{
… code…
}

Once again. I Load the script on wrappers “Shown” event, and IT DOES load needed value. Problem is HOW TO call this function later on, without reloading it.

Your script should be defined as

[code]XojoCustom.VeryBigForm.LoadValues = function() {

}[/code]

Otherwise it is only created within the scope of the parser and gets destroyed almost immediately.

Typo?

Followup:

Each developer who creates a control should be using a unique value in JavascriptNamespace. You can read more about Namespaces, why they’re important and how to register them on pages 12-14 of the WebSDK docs.

What the namespace gets you is a unique place to put the stuff that belongs to you and your controls within Javascript on the browser. In the case of your control, the namespace is always prefixed by XojoCustom, which is the top-level namespace so user code doesn’t inadvertently conflict with some other global object

  • XojoCustom = Root level namespace
  • VeryBigForm = Your control’s namespace

One thing of note is that you are not limited to functions in the namespace. This means that not only can you define properties like XojoCustom.VeryBigForm.enabled = true;, but you can also make more sub-namespaces. For instance, if you had more than one VeryBigForm object which could exist at the same time, you could do something like this:

XojoCustom.VeryBigForm.Control1 = {}; // Define the sub-namespace as a javascript object XojoCustom.VeryBigForm.Control1.value = 42; // Define the value of the specific object

Your namespace will exist for as long as the session exists, so if you are storing lots of data on the browser, make sure you clean it up when the control’s Close event fires, otherwise it’ll keep using that memory until the user navigates to another URL (or refreshes their browser to restart your app).

@Eli - yes, typo

@ Greg, thank you, but it is still not understandable.
If I try to do this:
XojoCustom.VeryBigForm.LoadValues = function() { …}

I got JavaScript error:
Could not execute returned javascript: Unexpected identifier
Source: XojoCustom.VeryBigForm.LoadValues = function() { var datapairs = [] … }

To elaborate further. My JavaScript is in a constant called JSMain. I replace new lines in that constant with space
(in ‘Shown’)
Dim JSMainR = JSMain.ReplaceAll (chr(13), " ")
ExecuteJavaScript(JSMainR)

JSMain goes like:
function LoadValues() { … }
LoadValues();

This loads the values. But if I need to load them triggered by another component, I must use the whole script, not just to call the existing “LoadValues”