向todo.js添加额外的字段
问题描述:
如何向todo.js添加额外的字段?向todo.js添加额外的字段
initialize: function() {
this.input = this.$("#new-todo");
Todos.bind('add', this.addOne, this);
Todos.bind('reset', this.addAll, this);
Todos.bind('all', this.render, this);
Todos.fetch();
},
我认为它上面的代码中那令人不安的是,#新待办事项是div id其中的文本字段。
我添加了另一个'this.input'的新字段的ID,但它没有拿起它。 如何添加其他元素?
答
我认为this.$
只在连接到视图的元素下面搜索。如果您的输入元素不在视图所连接的元素之外,那么您可以尝试仅使用$("#another-todo")
或类似的元素。
是这样的?这个.input = this。$(“another-todo”) – user901790
不,像这样:'this.anothertodo = $(“#another-todo”)'如果我理解正确的话。 –
这是行不通的,有什么我可以给你发送整个代码 – user901790