Well, it depends on the tier where the code is generated (Event execution on the client and server side)
- If the code is generated server side, the Java (or Net) code is executed.
- To publish JS properties and methods to be accessible from GeneXus code, you need to declare them in the External Object.
- To use the external JS resource, you have to add the reference to the HTML header, for instance, using the HeaderRawHTML Form method.
- If you define a variable based on the External Object in any GeneXus object, a constructor needs to be defined in the JS code.
- If you need to call a GeneXus event from a JS external code:
- declare the event in an External Object
- Events in GeneXus are always static, so in the External Object Events definition, you have to set the IsStatic property to TRUE. The Events can be called from other events, as if they were methods.
Look at this example in How to implement a dictionary data type using JS and server side code.
This is a canonical example where you interact with the window and execute events in GeneXus accordingly. In particular, this example shows how to interact with the scroll event.
Look at this example in How to execute GeneXus events from JS code using External Objects.
See How to interact with the Window Object's Methods
1. error spc0200: External Object X does not implement method 'scroll(' for C# Web environment ).
2. TypeError: X is not a constructor