我试图编写一个 ToDo-App,但我的复选框一开始就有问题......
模板:
<script type="text/x-handlebars">
{{view Todos.CreateTodoView id="new-todo" placeholder="What has to be done?"}}
{{#collection contentBinding="Todos.todosController" tagName="ul"}}
{{view Em.Checkbox titleBinding="content.title" valueBinding="content.isDone"}}
{{/collection}}
</script>
编码:
window.Todos = Ember.Application.create();
Todos.initialize();
Todos.Todo = Ember.Object.extend({
title: null,
isDone: false
});
Todos.todosController = Ember.ArrayController.create({
content: [],
createTodo: function(title) {
var todo = Todos.Todo.create({title: title});
this.pushObject(todo);
}
});
Todos.CreateTodoView = Ember.TextField.extend({
insertNewline: function() {
var value = this.get('value');
if (value) {
Todos.todosController.createTodo(value);
this.set('value', '');
}
}
});
..添加ToDo-Item时为什么没有添加标签的任何想法?