doAction( "ready" )
doAction( "ready" );
The JS API is fully initialized and all Areas were registered. The JS API will now listen and react to events
Examples
// Output a list of all registered Areas when the JS API is ready. DiviArea.addAction( 'ready', function() { var ids = DiviArea.listAreas(); console.log('JS API ready, following Areas found:', ids); });
// Instantly display the Popup "safety-notice" on page load. DiviArea.addAction( 'ready', function() { var popupId = 'safety-notice'; DiviArea.show( popupId ); });
Notes
All Areas (Popups) are registered during the ready action, in the following order:
- Popups that were designed in the Visual Builder are initialized
- Areas that were created with Divi Areas Pro
The plugin internally uses this pseudo-logic, to illustrate the action priority:
// Step 1: Register Popups that were created in the Visual Builder // via the Popups-Tab, with priority 1: DiviArea.addAction( 'ready', setupAreas, 1 ); // <- priority 1// Step 2: Register Areas that were created in the Divi Areas Pro // admin page, with priority 2: DiviArea.addAction( 'ready', setupAreas, 2 ); // <- priority 2