0
我曾試圖用木偶組合視圖來構建樹表組件。獲取樹模型數據的深度 - 複合視圖 - marionettejs
類似於this。
我參考Derick's sample使用marionettejs構建樹形菜單。
// The recursive tree view
var TreeView = Backbone.Marionette.CompositeView.extend({
template: "#node-template",
tagName: "ul",
initialize: function(){
this.collection = this.model.nodes;
}
});
// The tree's root: a simple collection view that renders
// a recursive tree structure for each item in the collection
var TreeRoot = Backbone.Marionette.CollectionView.extend({
childView: TreeView
});
我正在嘗試使用Table而不是UnOrder列表,根據樹的深度將CSS類應用於每個TR。
但是在這裏,我無法找到一個API來獲取模型的深度,同時呈現它。在遞歸調用期間有沒有辦法獲得深度?