doAction( “load” )

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

The load action is fired after the API was fully loaded, but before it is initialized – i.e. before any options are parsed or any Area is processed.

Params

This action does not have any params.

Examples

// Disable debugging by changing the Options object.
DiviArea.addAction( 'load', function() {
    DiviAreaConfig.debug = false;

    // Disable the "Debug.log" function by replacing it with an empty function.
    DiviArea.Debug.log = function() {}
});

Notes

This is always the first action that is fired by the JS API. You can use this action to overwrite core functions with your own code, like this basic example:

DiviArea.addAction( 'load', function() {
    var origFunction = DiviArea.show;

    DiviArea.show = function( showWhat ) {
        console.log( 'Custom Show Wrapper called!', showWhat );

        // Call the original `DiviArea.show` function.
        var res = origFunction( showWhat );
    
        if ( ! res ) {
            console.log( 'Could not show the area... is that name correct?', showWhat );
        }
    };
});

Was this article helpful?

Related Articles