gform/theme/scripts_loaded

Description

The gform/theme/scripts_loaded event can be used to initialize scripts that depend on Gravity Forms front-end form scripts, including the JavaScript gform object.

Usage

The gform/theme/scripts_loaded event can be used with the standard addEventListener method:

document.addEventListener('gform/theme/scripts_loaded', () => {
	// Do something.
});

Parameters

This event isn’t passed any parameters.

Examples

Adding an async filter

The following example shows how you can add an async filter that uses a method on the gform JavaScript object.

document.addEventListener('gform/theme/scripts_loaded', () => {
	gform.utils.addAsyncFilter('gform/submission/pre_submission', async (data) => {
		// Do something.
		return data;
	});
});

Placement

Your code snippet can be placed in an HTML field on your form or in a theme custom JavaScript file.

See also the JavaScript/jQuery section in this article: Where Do I Put This Code?

Since

This event was added in Gravity Forms v2.9.0

Source Code

This event is located in init() in /assets/js/src/theme/core/ready.js.