Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

improve

  • Loading branch information...
commit ad711dadc8fe36d9130c13d132d5f42363986c1d 1 parent e4cffda
@suupic authored
Showing with 33 additions and 22 deletions.
  1. 0  index.html
  2. +33 −22 js/app.js
View
0  index.html 100644 → 100755
File mode changed
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'
+});
Please sign in to comment.
Something went wrong with that request. Please try again.