Note that there are some explanatory texts on larger screens.

plurals
  1. POitem-specific actions in ember.js collection views
    primarykey
    data
    text
    <p>I'm just starting to play around with the ember.js library to see what it's all about. I want to display a table of data, and to the right of each row, have a delete button to delete that item from the table. I have no idea how to do this though. </p> <p>Note, I also tried to create a child view (ItemView) and use it inline within the {{#each ...}}...{{/each}} section, but ember.js complains about expecting a view class instead of ItemView, even though ItemView is defined using Ember.View.create. I would also like to know why that isn't working. Even the sample code for using a child view in an #each block in the documentation doesn't work. </p> <p>Even if I could declare a child view called ItemView to render each individual Item, I still wouldn't know how to get that particular view's removeItem action to know which item to remove from the itemsController collection. Is there a property of the View to get back the Item instance that the child view is bound to in a collection?</p> <p>Here is the part of my view template that has the list:</p> <pre><code>{{#each App.itemsController}} &lt;tr&gt; &lt;td&gt;{{itemName}}&lt;/td&gt; &lt;td&gt;&lt;a href="#" {{action "removeItem" on="click"}}&gt;Delete&lt;/a&gt;&lt;/td&gt; &lt;/tr&gt; {{/each}} </code></pre> <p>And here is my javascript:</p> <pre><code>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) { // ??? How do I figure out what item // the user wanted to remove? } }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload