applyFilters( “ignore_close_area” )

  1. Home
  2. Knowledge Base
  3. Codex
  4. JS API
  5. JS Filters
  6. applyFilters( “ignore_close_area” )
applyFilters( "ignore_close_area", ignore, area, reason );
applyFilters( "ignore_close_area_{key}", ignore, area, reason );

Allows to ignore the close_area request and force an area to stay open.

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

Params

ignore
(bool, required) Whether to ignore the close_area command and keep the area visible. Default: false.
area
(object, required) The Divi Area which will be hidden.
reason
(string, required) Identifies the action that triggered the close_area call.

Examples

// Remember the timestamp when the Area was made visible.
DiviArea.addAction( 'show_area', function( area ) {
    area.setData( 'opened_at', new Date().getTime() );
});

// Forces every Area to stay visible for at least 10 seconds.
DiviArea.addFilter( 'ignore_close_area', function( ignore, area, closeType ) {
    var openSince = (new Date().getTime() - area.getData( 'opened_at' )) / 1000;

    if ( openSince >= 10 ) {
        return false; // process the close-request.
    } else {
        console.log('Try again in', parseInt(10 - openSince), 'seconds');
        return true; // ignore the close-request.
    }
});

Notes

This filter is applied after any close_area action was fired.

However, DiviArea.hide() will always hide the Area without calling the ignore_close_area filter!

Was this article helpful?

Related Articles