I'm just starting to play with the ember.js library to find out that's all. I want to display a data table, and to the right of each row is a delete button to remove this item from the table. I do not know how to do that.
Notice I also tried to create a child view (ItemView) and use it inside the {{#each ...}} ... {{/ each}} section, but ember.js complains about waiting for the view class instead of the ItemView, although the ItemView is defined using Ember.View.create. I would also like to know why this is not working. Even the sample code for using the child view in the #each block in the documentation does not work.
Even if I can declare a child ItemView to display each individual item, I still donβt know how to get this particular view removeItem action to find out which item to remove from the itemsController collection. Is there a view property to return an instance of the element to which the child view in the collection is bound?
Here is the part of my view template that has a list:
{{#each App.itemsController}} <tr> <td>{{itemName}}</td> <td><a href="#" {{action "removeItem" on="click"}}>Delete</a></td> </tr> {{/each}}
And here is my javascript:
window.App = Ember.Application.create(); window.App.Item = Ember.Object.extend({ itemName: "defaultItemName" }); window.App.itemsController = Ember.ArrayProxy.create({ content: [] }); window.App.ListView = Ember.View.create({ templateName: 'listView', removeItem: function (event) {
Jeremy bell
source share