EN RU
Forum

Methodology

Technology

Toolbox

Libraries

Tutorials

Interaction of blocks

In the scope of the BEM methodology, blocks should be developed in a way that minimizes their dependency on each others' states. However, the ideal of fully independent blocks is not achievable in practice.

Block interaction can be implemented in the following ways:

Note Don't use DOM events for arranging interaction between blocks. DOM events are intended only for implementing internal procedures of a block.

The following i-bem.js APIs are provided for implementing interaction between blocks:

Access to block classes

You can get JS components corresponding to block classes via the module system. This is also true for blocks without DOM representation.

Access to block classes is needed for:

Example

Calling the close static method for the popup block will close all popups on the page.

modules.define('switcher', ['i-bem__dom', 'popup'], function(provide, BEMDOM, Popup) {

provide(BEMDOM.decl(this.name,
    {
        onSetMod : {
            'popup' : {
                'disabled' : function() {
                    Popup.close();
                }
            }
        }
    }
));

});