Created
October 14, 2013 13:39
-
-
Save anonymous/6975752 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> | |
<script src="http://cdnjs.cloudflare.com/ajax/libs/handlebars.js/1.0.0/handlebars.js"></script> | |
<script src="http://builds.emberjs.com.s3.amazonaws.com/tags/v1.0.0/ember.js"></script> | |
<meta charset=utf-8 /> | |
<title>JS Bin</title> | |
</head> | |
<body> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Todo = Ember.Object.extend({ | |
isDone: false | |
}); | |
Todos = Ember.Object.extend({ | |
todos: [], | |
remaining: function() { | |
return this.get("todos").filterBy("isDone", false).get("length"); | |
}.property("todos.@each") | |
}); | |
firstTodo = Todo.create(); | |
secondTodo = Todo.create(); | |
thirdTodo = Todo.create(); | |
todos = Todos.create({ | |
todos: [firstTodo, secondTodo] | |
}); | |
console.log("First run"); | |
console.log(todos.get("remaining")); | |
firstTodo.set("isDone", true); | |
console.log("After updating isDone property on firstTodo"); | |
console.log(todos.get("remaining")); | |
console.log("After adding third todo"); | |
todos.todos.pushObject(thirdTodo); | |
console.log(todos.get("remaining")); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment