【发布时间】:2015-12-18 12:21:29
【问题描述】:
如果你能以某种方式帮助我,请告诉我,我有点难以理解。
从一些 Marionette 应用程序逻辑开始:
app.js
//basic setup
this.Graph = new joint.dia.Graph;
this.Paper = new joint.dia.Paper({ width: 640, height: 480, model: this.Graph });
// [...] lots of code
//adding elements
app.Elements.add(element);
到目前为止一切顺利。现在是棘手的部分。我要收藏。
JointCollectionView.js
module.exports = Marionette.CollectionView.extend({
tagName: 'div',
className: 'row',
childView: JointView,
addChild: function(child, ChildView, index){
//does that make sense?
app.Graph.addCell(child);
//should i add it to collection?
if (child.shouldBeShown()) {
return Marionette.CollectionView.prototype.addChild.call(this, child, ChildView, index);
}
},
getChildView: function(item) {
return app.Graph.getCell(item);
}
//[...]
})
现在更加棘手。如何处理联合视图以使其与集合一起使用并显示 html 元素?
JointView.js
module.exports = joint.dia.ElementView.extend({ /* ?!?!?! */ });
//OR ?
module.exports = Marionette.ItemView.extend({
jointElementView: null, //this will be like above somewhere else...
initialize: function(options){
jointElementView = new JointElementView({ /* ... */ });
}
})
【问题讨论】:
-
它是如何为您工作的?
-
我实际上已经解决了这个问题。 JointElementView 是个坏主意,因为jointjs 不能那样工作。我将更新我的帖子,以便您可以相应地更改您的答案。由于您是唯一一个花时间研究它的人,因此您的观点是当之无愧的。抱歉耽搁了。圣诞节前忙:)
-
你去。已编辑。修正你的答案,我会批准它:)
标签: backbone.js marionette collectionview jointjs