Permalink
Browse files

improve

  • Loading branch information...
1 parent e4cffda commit ad711dadc8fe36d9130c13d132d5f42363986c1d @suupic committed Aug 6, 2012
Showing with 33 additions and 22 deletions.
  1. 0 index.html
  2. +33 −22 js/app.js
View
0 index.html 100644 → 100755
No changes.
View
55 js/app.js 100644 → 100755
@@ -1,33 +1,44 @@
-var App = Em.Application.create({
- name: 'TODO'
-});
-
-TodosView = Em.View.extend({
-
- add: function(event){
- console.log('clicked');
- TodosController.add();
- },
- done: function(event){
- console.log(event);
- },
- todoBinding: 'TodosController.content'
+// 模型
+Todo = Em.Object.extend({
+ text: null,
+ isDone: false,
+ changeStatus: function(){
+ if (this.isDone == false){
+ this.set('isDone',true)
+ }
+ else{
+ this.set('isDone',false)
+ }
+ }
});
-App.todo = Em.Object.create({
- text: 'eating',
- isDone: false
+var App = Em.Application.create({
+ name: 'TODO'
});
TodosController = Em.ArrayController.create({
content: [],
init: function(){
- var todo = App.todo;
- this.pushObject(todo);
},
- add: function(){
- var todo = App.todo;
- this.pushObject(todo);
+ add: function(text){
+ var todo = Todo.create({
+ text: text
+ })
+ this.pushObject(todo);
}
});
+TodosView = Em.View.extend({
+ add: function(event){
+ var myDate = new Date();
+ text = myDate.getMinutes() +':'+ myDate.getSeconds();
+ TodosController.add(text);
+ },
+ done: function(){
+ console.log(event.target);
+ var todo = this.get('context');
+ console.log(this);
+ console.log(this.get( 'content' ));
+ },
+ todoBinding: 'TodosController.content'
+});

0 comments on commit ad711da

Please sign in to comment.