Remove a child view

Removes a child view from a view. This method can remove child views that were added with the addChildView or addChildViews methods, as well as other child views in the parent view.

This method accepts up to three arguments. If only one argument is passed, the argument is determined to be placeholder_selector. In this case, view_id is set to the default view of the current component. In Layout, the main view is layout.ALL_VIEWS.

var layout = container.getComponent('Layout');

layout.addChildView('FlashMessage.View', function() {
  return new FlashMessageContentView({});
});
console.log('Child view added.');

layout.removeChildView('FlashMessageContentView');
console.log('Child view removed.');
NameTypeAttributesDescription
view_idstringThe identifier of the main view from which the child view will be removed. Most components have only one main view.
placeholder_selectorstringThe identifier of the view to be removed (specified as a value of a data-view or data-cms-area attribute).
view_namestring<optional>The internal identifier of the view to be removed. To get the internal identifier of a view, put the return value of addChildView in a variable, and then pass that variable as [view_name].

Returns null if the operation is successful. Otherwise, it throws an exception.

Leave a comment

Your email address will not be published. Required fields are marked *