doAction( “ready” )

  1. Home
  2. Knowledge Base
  3. Codex
  4. JS API
  5. JS Actions
  6. doAction( “ready” )
DiviArea.doAction( "ready" );

The JS API is fully initialized and all Areas were registered. The JS API will now listen and react to events

Params

This action does not have any params.

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:

  1. Popups that were designed in the Visual Builder are initialized
  2. Areas that were created with Divi Areas Pro

The plugin internally uses this pseudo-logic, to illustrate the action priority:

// Popups that were created in the Visual Builder via the Popups-Tab are registered with priority 1:
DiviArea.addAction( 'ready', setupAreas, 1 );  // <- priority 1

// Areas that were created in the Divi Areas Pro admin page are registered with priority 2:
DiviArea.addAction( 'ready', setupAreas, 2 );  // <- priority 2

Was this article helpful?

Related Articles