0
我剛剛開始與Backbone.js所以請原諒簡單的問題。骨幹 - 構建一個簡單的應用程序的意見
我正在通過標準的「Todo」示例並希望擴展「Todo」,以便它可以有多個字段。目前,「Todo」應用程序只是使用AppView中的單個字段來觸發收集中的新項目。
的index.html
<header id="header">
<h1>todos</h1>
<input id="new-todo" placeholder="What needs to be done?" autofocus>
</header>
App.js
app.AppView = Backbone.View.extend({
events: {
'keypress #new-todo': 'createOnEnter'
因此,我相信目前的結構是
APPVIEW
- >集(託多斯)
- >查看(待辦事項列表項)
我想提出新的項目模板自己的看法
APPVIEW
- >收集(託多斯)
- >查看(待辦事項列表項)
- >查看(TODO:新建項目)
我,如何這視圖中添加出頭到集合有點失落。 appview目前只是調用。
createOnEnter: function(e) {
if (e.which !== ENTER_KEY || !this.$input.val().trim()) {
return;
}
app.Todos.create(this.newAttributes());
this.$input.val('');
}
如何從我的新視圖中獲取對集合的引用?