Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

add item to list when click

  • Loading branch information...
commit e4cffdac0502299d035bd576a1103144c4afe02e 1 parent 746cbb9
@suupic authored
View
11 index.html
@@ -21,8 +21,15 @@
</head>
<body>
<script type="text/x-handlebars">
- {{#view App.MyView}}
- <h1>Hello world!</h1>
+ {{#view TodosView}}
+ <h1>{{App.name}}</h1>
+ {{isSelected}}
+ <a href="#" {{action "add"}}>add</a>
+ <ul>
+ {{#each TodosController.content}}
+ <li><a href="#" {{action "done"}}>{{text}}:{{isDone}}</a></li>
+ {{/each}}
+ </ul>
{{/view}}
</script>
View
34 js/app.js
@@ -1,7 +1,33 @@
-var App = Em.Application.create();
+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'
+});
-App.MyView = Em.View.extend({
- mouseDown: function() {
- window.alert("hello world!");
+App.todo = Em.Object.create({
+ text: 'eating',
+ isDone: false
+});
+
+TodosController = Em.ArrayController.create({
+ content: [],
+ init: function(){
+ var todo = App.todo;
+ this.pushObject(todo);
+ },
+ add: function(){
+ var todo = App.todo;
+ this.pushObject(todo);
}
});
+
View
0  js/templates/todosView.js
No changes.
Please sign in to comment.
Something went wrong with that request. Please try again.