微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

使用 StickIt 绑定到 Backbone Marionette 的 UI 哈希

如何解决使用 StickIt 绑定到 Backbone Marionette 的 UI 哈希

我正在使用 Marionette.js (v3.5.1) 构建 Backbone.js (v1.3.3) 应用程序,用于视图渲染和用于双向数据绑定的 Backbone.stickit。

有没有办法使用stickit 绑定到Marionette 的ui 哈希,而不是显式绑定到模板中元素的类或ID?我想,我有 ui 哈希,为什么不直接绑定到它,而不是以不同的方式定位同一元素(请参阅代码片段中的 bindings 对象)。

// view (view.js)
module.exports = Marionette.View.extend({

    template: require('../templates/sample.jst'),// want to bind to this hash
    ui: {
        input: '#js-some-input'
    },bindings: {
        // this works
        '#js-some-input'     : 'somemodelattribute'

        // these don't
        ':view.ui.input'     : 'somemodelattribute'
        '@ui.input'          : 'somemodelattribute'
        'this.getUI("input")': 'somemodelattribute'
        // etc . . .
    },onRender() {
        this.stickit();
    },onDestroy() {
        this.unstickit();
    }

});

// template (sample.jst)
<form name="someFormName">

    <input name="someInputName"
           type="text"
           id="js-some-input" />

</form>

来源:

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。