doAction( "close_area" )
doAction( "close_area", area, closeType ); doAction( "close_area_{key}", area, closeType );
Fired internally to trigger a stoppable close-request. If the request is not stopped, it ends in calling DiviArea.hide()
.
The dynamic part of the filter name is the sanitized Area key. See DiviAreaItem.theKey()
for details.
Params
-
area
-
(DiviAreaItem|null, required) The Divi Area that should be hidden.
A null-value instructs the plugin to close the top-most Area, which is identical to callingDiviArea.hide()
without a parameter. -
closeType
- (string, required) The event that caused the close_area action. It can be one of the following values:
Examples
// Output a console message when an Area should be closed. DiviArea.addAction( 'close_area', function( area, closeType ) { if ( area ) { var key = area.getKey(); console.log( 'The area', key, 'is about to be closed. Reason:', closeType ); } else { console.log( 'The top-most area is closed. Reason:', closeType ); } });
Notes
Possible close-types can be:
-
default
- The user clicked the default close button of the Area.
-
custom
- The user clicked a custom close button inside the Area.
-
esc
- The user pressed the escape key (only for Popups).
-
overlay
- The user clicked the background overlay (only for Popups).
The close_area
action can be stopped by reacting to the ignore_close_area
filter.
If you want to hide an Area, it is easier to call DiviArea.hide(area)
. The action is used internally by the JS API to allow other scripts to intercept and cancel the close request.