向todo.js添加额外的字段

时间:2011-11-29 08:41:07

标签: ruby-on-rails-3 backbone.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();
},

我认为上面的代码令人不安,#new-todo是文本字段所在的div id。

我使用新字段的id添加另一个'this.input',但它不会提取它。 如何添加其他元素?

1 个答案:

答案 0 :(得分:0)

我认为this.$只搜索连接到视图的元素下方。如果您的输入元素位于视图所连接的元素之外,您可以尝试仅使用$("#another-todo")或类似的。

相关问题