doAction( “load” )

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.

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

Need Support?

Can't find the answer you're looking for?
Get in touch with us