blear.ui.mobile-picker

1.0.1 • Public • Published

blear.ui.mobile-picker

npm module build status coverage

联动实例

配合blear.classes.linkage来实现数据联动。

var mobilePicker = new MobilePicker({
    title: '所在地区',
    length: 2
});
var linkage = new Linkage({
    length: 2
});
var urls = [
    '/api/district/provinces',
    '/api/district/cities'
];

linkage.on('getData', function (index, parent, done) {
    api({
        url: urls[index],
        query: {
            parent: parent
        }
    }, function (err, list) {
        if (err) {
            list = [];
        }

        done(list);
    });
});

linkage.on('changeList', function (index, list) {
    mobilePicker.render(index, list);
});

linkage.on('changeValue', function (index, value) {
    mobilePicker.changeValue(index, value);
});

linkage.ready(function () {
    mobilePicker.on('change', function (index, value) {
        linkage.change(index, value);
    });

    mobilePicker.on('setValue', function (value) {
        linkage.setValue(value);
    });
});

Package Sidebar

Install

npm i blear.ui.mobile-picker

Weekly Downloads

2

Version

1.0.1

License

MIT

Last publish

Collaborators

  • cloudcome