问题描述
我正在使用 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 (将#修改为@)