I've changed your app a little. Before you had two instances of Ember.Application
called App
and Todo
operating in the same scope. By default, an Ember App uses the body
element as the rootElement
(where your app is going to render), so your apps were colliding.
If you really need two apps running on the same page, use Application#rootElement
to inform the selector of the element you want the apps to render. I would say you should avoid using the body
as rootElement
when you have multiple applications sharing the same document (if that's what you wanted).
As per your image, I don't think you need two apps, and I'm assuming you just want the To Do app, so I have removed App
, leaving only Todo
(see fixed jsbin).
I have noticed that all your HTML was static and you were not using Handlebars at all, as well as some incorrect js references which have been fixed.
Instead of doing the following:
<section id="main">
<ul id="todo-list">
<li class="completed">
<input type="checkbox" class="toggle">
<label>Learn Ember.js</label><button class="destroy"></button>
</li>
<li>
<input type="checkbox" class="toggle">
<label>...</label><button class="destroy"></button>
</li>
<li>
<input type="checkbox" class="toggle">
<label>Profit!</label><button class="destroy"></button>
</li>
</ul>
<!-- more stuff-->
Use Handlebars, as it provides the {{each}}
helper, which allows you do iterate through your collection like this:
<ul id="todo-list">
{{#each filteredTodos itemController="todo"}}
<li {{bindAttr class="isCompleted:completed isEditing:editing"}}>
{{#if isEditing}}
{{view Todos.EditTodoView todoBinding="this"}}
{{else}}
{{view Ember.Checkbox checkedBinding="isCompleted" class="toggle"}}
<label {{action "editTodo" on="doubleClick"}}>{{title}}</label>
<button {{action "removeTodo"}} class="destroy"></button>
{{/if}}
</li>
{{/each}}
</ul>
This will create a li
element for each model in your controller (in this case, from the computed filteredTodos
).
I strongly recommend you to dive into the guides to learn more about ember.
script
tag? – MilkyWayJoe