Giter Site home page Giter Site logo

Comments (8)

tyv avatar tyv commented on May 27, 2024

same need to be added to blocks (look below), because they didn't trigger dom/jquery change at all
checkbox: https://github.com/bem/bem-components/blob/v1/common.blocks/checkbox/checkbox.js#L50
radiobox (didnt test): https://github.com/bem/bem-components/blob/v1/common.blocks/radiobox/radiobox.js#L85 and https://github.com/bem/bem-components/blob/v1/common.blocks/radiobox/radiobox.js#L177

from bem-components.

dfilatov avatar dfilatov commented on May 27, 2024

You should use BEM-events and binds like BEM.blocks['input'].on(domElem, 'change', ...) where domElem is form, instead using of low-level DOM-events.

from bem-components.

tyv avatar tyv commented on May 27, 2024

I dont know what exactly form elements will appear in my form.
so do I need in this case to repeat this subscription for all?

from bem-components.

dfilatov avatar dfilatov commented on May 27, 2024

You need introduce high-level block, e.g. form, with approximately the following code (in case of v2):

modules.define('i-bem__dom', function(provide, BEMDOM) {

BEMDOM.decl('form', {
    onSetMod : {
        'js' : {
            'inited' : function() {
                ['input', 'radio', 'checkbox', 'select'].forEach(function(block) {
                    BEMDOM.blocks[block].on(this.domElem, 'change', this._onControlChange, this);
                }, this);
            },
            ...
        },
        ...
    },

    _onControlChange : function(e) {
        // e.target is a block that has changed
    },
    ...
});

provide(BEMDOM);

});

from bem-components.

dfilatov avatar dfilatov commented on May 27, 2024

May be later we introduce in v2 subscription to all block to reduce the code:

 ['input', 'radio', 'checkbox', 'select'].forEach(function(block) {
    BEMDOM.blocks[block].on(this.domElem, 'change', this._onControlChange, this);
}, this);

to:

BEMDOM.blocks['*'].on(this.domElem, 'change', this._onControlChange, this);

from bem-components.

tyv avatar tyv commented on May 27, 2024

thanks!

from bem-components.

narqo avatar narqo commented on May 27, 2024

@dfilatov Maybe we could implement this form block as part of bem-components#v2?

from bem-components.

dfilatov avatar dfilatov commented on May 27, 2024

@narqo I don't mind, but we must think about the interface (methods, events, etc).

from bem-components.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.