如何使用主干木偶js获得网格

时间:2013-06-10 12:12:11

标签: java spring-mvc twitter-bootstrap javascript-framework marionette

请使用backbone.marionnette.js

帮助我实现以下网格
1. a link to add new row
2. row will have text boxes where the data can be entered.

因为我是backbone.marionette.js的新手,我甚至无法弄清楚该做什么以及从哪里开始

1 个答案:

答案 0 :(得分:3)

您需要使用集合视图(请参阅https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.collectionview.md)。这将为集合中的每个模型实例显示相同的视图(称为项视图)。

然后,您的项目视图需要具有匹配的模板,该模板将包含文本框。

感谢Marionette的魔力,添加一行只是意味着直接在集合中添加新模型:

myCollection.create({ name: "foo" });

或添加现有模型:

var m = new MyModel({ name: "foo" });
myCollection.add(m);

所以你的“添加新行的链接”只会创建一个新模型并将其添加到集合中。

我的free sample book on Marionette更详细地介绍了使用模型和集合视图。

由于您是Marionette的新手,您还可以通过阅读我关于该主题的博文来了解更多信息:http://davidsulc.com/blog/category/backbone-js/backbone-marionette/