doAction( “init_area” )

  1. Home
  2. Knowledge Base
  3. Codex
  4. JS API
  5. JS Actions
  6. doAction( “init_area” )
doAction( "init_area", area );
doAction( "init_area_{key}", area );

Fired right after an area was fully initialized and is ready to be displayed.

The dynamic part of the filter name is the sanitized Area key. See DiviAreaItem.theKey() for details.

Params

area
(DiviAreaItem, required) The Area which was initialized.

Examples

// Output a console comment upon initializing an Area.
DiviArea.addAction( 'init_area', function( area ) {
    var areaKey = area.getKey();
    console.log( 'Area is ready:', key );
});

// Instantly display the Divi Area with the ID "safety-notice".
// Notice, how the ID "safety-notice" changes to "safety_notice" in the hook name!
DiviArea.addAction( 'init_area_safety_notice', function( area ) {
    DiviArea.show( 'safety-notice' );
});

Notes

At this stage, the Area is not visible. This is the earliest point when DiviArea.show() can display the area.

Though the Area is hidden, it’s still in the DOM and can be accessed by other scripts for a short time. See details on the area_preparation_time filter for more information.

Was this article helpful?

Related Articles