讓我知道如果你能以某種方式幫助我,我有點掙扎着想我的頭。製作JointJs&Backbone/Marionette與收藏品(內部的HTML項目)
開始與一些木偶應用邏輯:
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({ /* ... */ });
}
})
它是如何爲你工作的? – seebiscuit
我已經真正解決了這個問題。由於jointjs不以這種方式工作,JointElementView是一個糟糕的主意。我會更新我的文章,以便相應地更改您的答案。既然你是唯一一個投入一些時間看待它的人,你的觀點是當之無愧的。對不起,延遲壽。在聖誕節前忙碌:) – proxylittle
你走了。編輯。修復你的答案,我會批准它:) – proxylittle