1.1.10 • Published 10 years ago

bind-ui-elements v1.1.10

Weekly downloads
3
License
MIT
Repository
github
Last release
10 years ago

bind-ui-elements

npm

A small utility method to help bind children elements to a context. For convenience when using module pattern in jQuery

Install

npm install --save bind-ui-elements

<script src="https://npmcdn.com/bind-ui-elements@1.1.4/dist/index.js"></script>

##OOP

import bindUiElements from 'bind-ui-elements';

class Component {
    constructor($el, config) {
        this.$el = $el;
        this.cfg = Object.assign({}, Component.defaultCfg, config);
        bindUiElements(this);
        this.initalize();
    }
    initalize() {
        //$button now has been attached to component's instance
        this.$button.on('click', function() {

        });

        //$link now has been attached to component's instance
        this.$link.on('click', function() {

        });
    }
}

Component.defaultCfg = {
    ui: {
        $button: '.js-button',
        $link: '.js-link'
    }
}

export default Component;

Singleton

var component = {
    cfg: {
        ui: {
            '$button': '.js-button',
            '$link': '.js-link'
        }
    },
    init ($el) {
        this.$el = $el;
        bindUiElements(this);

        //$button now has been attached to component's instance
        this.$button.on('click', function() {

        });

        //$link now has been attached to component's instance
        this.$link.on('click', function() {

        });
    }
};

Test

npm test

1.1.10

10 years ago

1.1.9

10 years ago

1.1.8

10 years ago

1.1.7

10 years ago

1.1.6

10 years ago

1.1.5

10 years ago

1.1.4

10 years ago

1.1.3

10 years ago

1.1.2

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.5

10 years ago

1.0.4

10 years ago

1.0.3

10 years ago

1.0.2

10 years ago

1.0.1

10 years ago

1.0.0

10 years ago