我想使用Backbone来创建如下的菜单
我已经编写了如下代码,但它不起作用。
//create a menu which has a list of item
var MenuList = Backbone.RelationalModel.extend({
relations: [{
type: Backbone.HasMany,
key: 'itemList',
relatedModel: 'MenuItem',
reverseRelation: {
key: 'upperItem',
},
}]
});
//each item can be menu list
var MenuItem = Backbone.RelationalModel.extend({
relations: [{
type: Backbone.HasOne,
key: 'subMenu',
relatedModel: 'MenuList',
reverseRelation: {
key: 'upperItem',
},
}]
});
任何帮助将非常感谢。或者任何基于骨干的框架都能满足要求?谢谢。