S
S
someserj2017-03-13 17:16:43
css
someserj, 2017-03-13 17:16:43

What about JS and prefixes in BEM (BEM)?

I saw somewhere that there are some prefixes for classes like js-classname, but in the office. I did not find such documentation.
so what to prescribe to elements, prefixes to classes or id? to refer to them in js

Answer the question

In order to leave comments, you need to log in

3 answer(s)
I
i, 2017-03-13
@ilyarsoftware

From the history of BEM development https://ru.bem.info/methodology/history/
real
Example: https://codepen.io/ilyar/pen/WZzzmP?editors=1010#0

<div class="myBlock i-bem" data-bem='{"myBlock":{"param": "val"}}'>
    ...
</div>

modules.define('myBlock', ['i-bem-dom'], function (provide, bemDom) {

    provide(bemDom.declBlock(this.name, /* методы экземпляра */ {

            onSetMod: {
                'js': {
                    'inited': function () {
                        this.domElem[0].innerHTML = this.__self.parseParams(this.params);
                    }
                }
            }

        }, /* статические методы */ {

            parseParams: function (params) {
                return '<pre>' + JSON.stringify(params, null, ' ') + '</pre>';
            }

        }
    ));

});

There is also a BEM + React.js implementation https://github.com/bem/bem-react-core, an example https://scrimba.com/c/cQR4bTr and theory https://www.youtube.com/playlist? list=PLAmtJdts5To...

I
igumenov, 2017-03-13
@igumenov

Usually through js-class_name classes

S
sim3x, 2017-03-13
@sim3x

id is not used
js-do_shit allows you to understand that somewhere in js there is a function that is attached to this class and it does shit

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question