Nested View Not Updating Ember.js - ember.js

Some background before I get right to the problem. I've got some data (random numbers in this case), and I will need to be able to visualize this data in multiple ways. I've only implemented a table and line view in the fiddle, in prod I will have more ways to visualize the data (pie, bar, etc...), and there will be multiple sections.
Here is the fiddle.
I can correctly change the type I want to display, but I can't seem to get the view to update whenever I update the nested view. I'm probably missing something really easy, so the title of this question maybe loaded. If that's the case I apologize, but I'd greatly appreciate any help.
Handlebars:
<script type="text/x-handlebars" data-template-name="index">
{{#each App.Controller.content}}
{{#view App.ChartTypeContainer contentBinding="this"}}
{{#each chartTypesWithSelected}}
<a href="#" {{action switchChartType this target="view"}}>
{{#if selected}}
<strong>{{display}}</strong>
{{else}}
{{display}}
{{/if}}
</a>
{{/each}}
{{/view}}
{{#if currentView}}
{{view currentView}}
{{/if}}
{{/each}}
</script>
<script type="text/x-handlebars" data-template-name="table">
<table>
<thead>
<tr>
{{#each view.data.headings}}
<th>{{name}}</th>
{{/each}}
</tr>
</thead>
<tbody>
{{#each view.data.data}}
<tr>
{{#each values}}
<td>{{this}}</td>
{{/each}}
</tr>
{{/each}}
</tbody>
</table>
</script>
<script type="text/x-handlebars" data-template-name="line">
</script>
js:
App = Em.Application.create({
getRandomData: function(){
// Generate between 1-3 random headings
var headings=[],
headingCount = (Math.floor(Math.random() * 5) + 1),
data=[];
for(var i = 0; i < headingCount; i++){
headings.push({name: 'heading ' + i});
}
// Generate between 5 and 10 rows of random data
for(var i = 0; i< (Math.floor(Math.random() * 10) + 5);i++){
var values = [];
for(var j=0; j< headingCount;j++){
values.push((Math.floor(Math.random() * 100) + 1));
}
data.push({values: values});
}
return {headings: headings, data: data};
},
ready: function(){
Em.View.create({templateName:'index'}).appendTo('body');
}
});
App.chartFactory = Em.Object.create({
create: function(key, data){
switch(key){
case 'table':
return App.TableView.create({data: data || App.getRandomData()});
case 'line':
return App.LineView.create();
default:
return;
}
}
});
/* MODELS */
App.ChartType = Em.Object.extend({
key: '',
display: ''
});
App.Section = Em.Object.extend({
title: '',
chartTypes: [],
chartTypesWithSelected: function(){
var currentSelected = this.get('selectedChartType');
var types = this.get('chartTypes');
var thing = types.map(function(item){
item.set('selected', item.key === currentSelected);
return item;
});
return thing;
}.property('chartTypes.#each', 'selectedChartType'),
data: {},
selectedChartType: '',
selectedChartTypeObserver: function() {
var selectedChartType = this.get('selectedChartType');
alert('changin chart type to: ' + selectedChartType);
App.chartFactory.create(selectedChartType);
}.observes('selectedChartType'),
currentView: null
});
/* VIEWS */
App.ChartTypeContainer = Em.View.extend({
switchChartType: function(chartType) {
this.get('content').set('selectedChartType', chartType.key);
}
})
App.TableView = Em.View.extend({
templateName: 'table',
data: {}
});
App.LineView = Em.View.extend({
templateName:'line',
data: {},
didInsertElement: function(){
var data = App.getRandomData();
var headings = data.headings.map(function(item){
return item.name;
});
var series = data.data.map(function(item){
return {data: item.values};
});
this.$().highcharts({
title: null,
series: series,
xAxis: {categories: headings},
yAxis: {min: 0, max: 100, title: {text: 'Random Numbers'}}
});
}
})
/* CONTROLLER */
App.Controller = Em.Object.create({
content: [
App.Section.create({
title: 'First Section',
chartTypes: [
App.ChartType.create({key: 'table', display: 'Table Display'}),
App.ChartType.create({key: 'line', display: 'Line Display'})
],
selectedChartType: 'table', // CHANGE HERE TO SEE THE OTHER VIEW, use 'line' or 'table'
currentView: App.chartFactory.create('table') // CHANGE HERE TO SEE THE OTHER VIEW, use 'line' or 'table'
})
]
});
UPDATE:
Setting the newly created view on the next run cycle using Ember.run.next seems to produce the required behavior correctly. Updated Fiddle

I suggest taking a look at the official ember guides. They've gotten really good lately and can shed some light on best practices and ways to not "fight" the framework.
I forked your fiddle and provided something that is closer to "the true ember way" when it comes to showing multiple views for the same underlying data as you are trying to do. In my opinion, manually creating and/or attaching views to the DOM is an anti-pattern in ember.
The basic approach is having a resource represent your data, and then routes under that resource that map to the templates that you want to render. What I've done is provide a template for the resource that merely has links to the two routes beneath it and an {{outlet}} into which those templates will get rendered. I removed your manual creation and swapping of views. By default I have it transition to the chart view so that you don't just see a blank page with links.
As with any framework, if you find yourself writing a ton of boilerplate code and things aren't working properly, that's probably a good sign that you're fighting the framework. Or the framework is bad. :P

Related

Ember Js Adding A Model Which is Dynamically Rendered On the UI

Hi all I have an issue i want to add another item to my model that is dynamically rendered on the UI.
However after i add it It still doest render on the UI. Do I need to call a function after adding it to the list of models?
Here is an example:
http://emberjs.jsbin.com/mugodifiki/edit?html,js,output
on clicking on an image it is suppose to add a predefined model to the array and display it on the UI
This is clearly an issue caused from the integration with owlcarousellibrary. A simple example of dynamically changing the model and rendering the ui, in plain emberjs, can be found here,
http://emberjs.jsbin.com/lodetofere/edit?html,js,output (simply click on the list).
This specific issue is caused due to the modifications of the DOM by the owlcarousel library. So to solve this, it is required to refresh the owlcarousel after changing the model and restoring the initial state of the dom.
Example,
http://emberjs.jsbin.com/qanocidoye/edit?html,js
The content part of the template is actually refreshed when the model changes by toggling a property and the carousel is reinitialized.
hbs
<script type="text/x-handlebars" data-template-name="components/test-component">
{{#if refresh}}
{{partial "owlContent"}}
{{else}}
{{partial "owlContent"}}
{{/if}}
</script>
<script type="text/x-handlebars" data-template-name="_owlContent">
<div class="owl-carousel owl-theme">
{{#each titleModels}}
<div class="item">
<img {{action "owlItemClicked" this on="click" }} {{bind-attr src=img}}>
</div>
{{/each}}
</div>
</script>
js
App.TestComponentComponent = Ember.Component.extend({
// classNames: ['owl-carousel', 'owl-theme'],
items: 8,
touchDrag: true,
mergeFit: false,
center: true,
addClassActive: true,
mouseDrag: true,
slideSpeed : 1000,
margin: 2,
refresh:false,
initCarousel:function(){
var self = this;
var options = {};
options.items = self.get('items');
options.touchDrag = self.get('touchDrag');
options.mergeFit = self.get('mergeFit');
options.center = self.get('center');
options.addClassActive = self.get('addClassActive');
options.mouseDrag = self.get('mouseDrag');
options.slideSpeed = self.get('slideSpeed');
options.margin = self.get('margin');
self._options = options;
self._owl = self.$(".owl-carousel").owlCarousel(options);
},
didInsertElement: function(){
this.initCarousel();
},
refreshCarousel:function(){
var self = this;
Em.run.next(function(){
self.initCarousel();
});
}.observes('refresh'),
actions: {
owlItemClicked: function(titleModel) {
var self = this;
var content = "<div class=\"item dodgerBlue\"><h1>test</h1></div>";
var newModel = Ember.Object.create({ index: 3, img: "http://www.cs.rice.edu/~dwallach/comp314_f99_ga/%257Eavinash/comp314/project3/pretty/pic1s.jpg"});
console.log(this.get('titleModels'));
//THIS ADDS IT TO THE MODEL BUT IS NOT RENDERED ON UI
this.get('titleModels').push(newModel);
alert('new model has been added');
console.log(this.get('titleModels'));
this.toggleProperty("refresh");
}
}
});
You may come up with a more elegant solution but this is the main idea.

Weird binding with Ember.Select value

I'm having a weird issue with the Ember.Select view when I try to bind its value to a model.
Here is an abstract of what I'm doing, the complete jsbin can be found here:
Using JavaScript: http://jsbin.com/jayutuzazi/1/edit?html,js,output
Using CoffeeScript: http://jsbin.com/nutoxiravi/2/edit?html,js,output
Basically what I'm trying to do is use an attribute of a model to set an attribute of another model.
I have the Age model like this
App.Age = DS.Model.extend({
label: DS.attr('string'),
base: DS.attr('number')
});
And an other model named Person like this
App.Person = DS.Model.extend({
name: DS.attr('string'),
ageBase: DS.attr('number')
});
The template looks like this:
<!-- person/edit.hbs -->
<form>
<p>Name {{input value=model.name}}</p>
<p>
Age
{{view "select" value=model.ageBase
content=ages
optionValuePath="content.base"
optionLabelPath="content.label"}}
</p>
</form>
What I am trying to do is have a select in the Person edit form that lists the ages using base as value and label as label.
I expect the correct value to be selected when loading and to change when the selected option changes.
Has can be seen in the jsbin output, the selected is correctly populated but it sets the ageBase value of the edited person to undefined and does not select any option. The model value is correctly set when an option is selected though.
Am I doing something wrong ? Is it a bug ? What am I supposed to do to make this work ?
Thank you :)
You can conditionally render based on fulfilment of the ages as follows, since select doesn't handle promises (more on that below):
{{#if ages.isFulfilled}}
{{view "select" value=ageBase
content=ages
optionValuePath="content.base"
optionLabelPath="content.label"}}
{{/if}}
I updated your JsBin demonstrating it working.
I also illustrate in the JsBin how you don't have to qualify with model. in your templates since object controllers are proxies to the models they decorate. This means your view doesn't have to be concerned with if a property comes from the model or some computed property on the controller.
There is currently a PR #9468 for select views which I made a case for getting merged into Ember which addresses some issues with selection and option paths. There is also meta issue #5259 to deal with a number of select view issues including working with promises.
From issue #5259 you will find that Ember core developer, Robert Jackson, has some candidate select replacements. I cloned one into this JsBin running against latest production release version of Ember.
There is nothing at all preventing you using Roberts code as a select view replacement in your app. Asynchronous collections/promises will just work (and it is MUCH faster rendering from the benchmarks I have seen).
The template for that component is just:
{{#if prompt}}
<option disabled>{{prompt}}</option>
{{/if}}
{{#each option in resolvedOptions}}
<option {{bind-attr value=option.id}}>{{option.name}}</option>
{{/each}}
The js of the component is:
App.AsyncSelectComponent = Ember.Component.extend({
tagName: 'select',
prompt: null,
options: null,
initialValue: null,
resolvedOptions: null,
resolvedInitialValue: null,
init: function() {
var component = this;
this._super.apply(this, arguments);
Ember.RSVP.hash({
resolvedOptions: this.options,
resolvedInitialValue: this.initialValue
})
.then(function(resolvedHash){
Ember.setProperties(component, resolvedHash);
//Run after render to ensure the <option>s have rendered
Ember.run.schedule('afterRender', function() {
component.updateSelection();
});
});
},
updateSelection: function() {
var initialValue = Ember.get(this, 'resolvedInitialValue');
var options = Ember.get(this, 'resolvedOptions') || [];
var initialValueIndex = options.indexOf(initialValue);
var prompt = Ember.get(this, 'prompt');
this.$('option').prop('selected', false);
if (initialValueIndex > -1) {
this.$('option:eq(' + initialValueIndex + ')').prop('selected', true);
} else if (prompt) {
this.$('option:eq(0)').prop('selected', true);
}
},
change: function() {
this._changeSelection();
},
_changeSelection: function() {
var value = this._selectedValue();
this.sendAction('on-change', value);
},
_selectedValue: function() {
var offset = 0;
var selectedIndex = this.$()[0].selectedIndex;
if (this.prompt) { offset = 1; }
return Ember.get(this, 'resolvedOptions')[selectedIndex - offset];
}
});
The problem is that in:
{{view "select" value=model.ageBase
When the app starts, value is undefined and model.ageBase gets synchronized to that before value is synchronized to model.ageBase. So, the workaround is to skip that initial undefined value.
See: http://jsbin.com/rimuku/1/edit?html,js,console,output
The relevant parts are:
template
{{view "select" value=selectValue }}
controller
App.IndexController = Ember.Controller.extend({
updateModel: function() {
var value = this.get('selectValue');
var person = this.get('model');
if ( value ) { // skip initial undefined value
person.set('ageBase', value);
}
}.observes('selectValue'),
selectValue: function() {
// randomly used this one
return this.store.find('age', 3);
}.property()
});
givanse's answer should work.
I don't think it's because value is undefined, but because value is just an integer (42) and not equal to any of the selects content, which are Person objects ({ id: 2, label: 'middle', base: 42 }).
You could do something similar to what givens suggests or use relationships.
Models
//
// Models
//
App.Person = DS.Model.extend({
name: DS.attr('string'),
ageBase: DS.belongsTo('age', { async: true })
});
App.Age = DS.Model.extend({
label: DS.attr('string'),
base: DS.attr('number')
});
//
// Fixtures
//
App.Person.reopenClass({
FIXTURES: [
{ id: 1, name: 'John Doe', ageBase: 2 }
]
});
App.Age.reopenClass({
FIXTURES: [
{ id: 1, label: 'young', base: 2 },
{ id: 2, label: 'middle', base: 42 },
{ id: 3, label: 'old', base: 82 }
]
});
Template:
<h1>Edit</h1>
<pre>
name: {{model.name}}
age: {{model.ageBase.base}}
</pre>
<form>
<p>Name {{input value=model.name}}</p>
<p>
Age
{{view "select" value=model.ageBase
content=ages
optionValuePath="content"
optionLabelPath="content.label"}}
</p>
</form>
Ok, I found a solution that I think is more satisfying. As I thought the issue was coming from ages being a promise. The solution was to ensure that the ages list was loaded before the page was rendered.
Here is how I did it:
App.IndexRoute = Ember.Route.extend({
model: function() {
return Ember.RSVP.hash({
person: this.store.find('person', 1),
ages: this.store.findAll('age')
});
}
});
That's it! All I need from there is to change the view according the new model:
{{#with model}}
<form>
<p>Name {{input value=person.name}}</p>
<p>
Age
{{view "select" value=person.ageBase
content=ages
optionValuePath="content.base"
optionLabelPath="content.label"}}
</p>
</form>
{{/with}}
The complete working solution can be found here: http://jsbin.com/qeriyohacu/1/edit?html,js,output
Thanks again to #givanse and #Larsaronen for your answers :)

How to set Default Value in Ember js

Using Below code i have created Ember View.
<script type="text/x-handlebars">
<h2>Welcome to Ember.js</h2>
{{outlet}}
</script>
<script type="text/x-handlebars" data-template-name="index">
<div>
{{view "select" content=model prompt="Please select a name" selectionBinding="controllers.comboBox.model" optionValuePath="content.title" optionLabelPath="content.body" }}
</div>
<div>
{{view "select" content=model1 prompt="Please select a name" optionValuePath="content.title" optionLabelPath="content.title" }}
</div>
</script>
and App.Js
App = Ember.Application.create({
});
App.Router.map(function () {
});
App.IndexRoute = Ember.Route.extend({
model: function () {
return posts;
}
});
App.IndexController = Em.ArrayController.extend({
needs: ["comboBox"],
sendValueToServer: function () {
document.getElementById("comboval").value = this.get("controllers.comboBox.model.title");
}.observes("controllers.comboBox.model"),
model1: function () {
var valueq = this.get('controllers.comboBox.model.title');
console.log("value "+valueq);
return posts1;
}.property("controllers.comboBox.model")
});
App.ComboBoxController = Em.Controller.extend({
model: null,
});
App.ComboBox1Controller = Em.Controller.extend({
model1: null,
});
posts = [{
title: "Raja",
body: "There are lots of à la carte software environments in this world."
}, {
title: "Broken Promises",
body: "James Coglan wrote a lengthy article about Promises in node.js."
},
{
title: "Broken",
body: "James Coglan wrote a lengthy article about Promises in node.js."
}
];
posts1 = [{
title: "Raja",
body: "There are lots of à la carte software environments in this world."
}, {
title: "Broken Promises",
body: "James Coglan wrote a lengthy article about Promises in node.js."
},
{
title: "Broken",
body: "James Coglan wrote a lengthy article about Promises in node.js."
}
];
Above code using Prompt I was showing "Please select a name" Default Value.
but Initially i dont want Please select a name default value.
my requirement is need to show second value as a default value.
how can i do this.
In association to the question mentioned here,
Second dropdown not calling EveryTime Based on First drop down
To set a default value all it is required is to set a value to the bound property of the specific drop down.
http://emberjs.jsbin.com/loqivasova/1/edit
js
App.ComboBoxController = Em.Controller.extend({
model: posts[0],
});
if however it is required to also modify the second drop down based on this default value, then just add on("init") to the setComboBox1Model1 function,
js
setComboBox1Model1:function(){
var valueq = this.get('controllers.comboBox.model.title');
var valueFromPosts1 = posts1.findBy("title",valueq);
this.set("controllers.comboBox1.model1",valueFromPosts1?valueFromPosts1:null);
}.observes("controllers.comboBox.model").on("init")
http://emberjs.jsbin.com/jogaqinugi/1/edit?html,js,output
If it is required to set the value after the view has rendered, then you should use a view
js
App.IndexView = Em.View.extend({
setDefaulValue:function(){
this.set("controller.controllers.comboBox.model",posts[0]);
}.on("didInsertElement")
});
http://emberjs.jsbin.com/qugefipefi/1/edit?html,js,output

select dropdown with ember

I'm trying to produce a select input and pass the selected object to the change event on the view. The ember contact example uses a <ul> but with a select the view needs to be outside the each otherwise the change even isn't fired.
Here is the view js:
App.SelectView = Ember.View.extend({
change: function(e) {
//event for select
var content = this.get('content');
console.log(content);
App.selectedWidgetController.set('content', [content]);
},
click: function(e) {
//event for ul
var content = this.get('content');
console.log(content);
App.selectedWidgetController.set('content', [content]);
}
});
The ul from the example works:
<ul>
{{#each App.widgetController.content}}
{{#view App.SelectView contentBinding="this"}}
<li>{{content.name}}</li>
{{/view}}
{{/each}}
</ul>
But if I replace html directly, the change event isn't fired (which makes sense)
<select>
{{#each App.widgetController.content}}
{{#view App.SelectView contentBinding="this"}}
<option>{{content.name}}</option>
{{/view}}
{{/each}}
</select>
So I guess the select has to be wrapped in the view.. in which case how do I pass the relevant object?... This code results in the entire array being passed:
{{#view App.select_view contentBinding="App.widgetController.content"}}
<select>
{{#each App.widgetController.content}}
<option>{{name}}</option>
{{/each}}
</select>
{{/view}}
Ember now has a built-in Select view.
Here's a usage example:
var App = Ember.Application.create();
App.Person = Ember.Object.extend({
id: null,
firstName: null,
lastName: null,
fullName: function() {
return this.get('firstName') + " " + this.get('lastName');
}.property('firstName', 'lastName').cacheable()
});
App.selectedPersonController = Ember.Object.create({
person: null
});
App.peopleController = Ember.ArrayController.create({
content: [
App.Person.create({id: 1, firstName: 'Yehuda', lastName: 'Katz'}),
App.Person.create({id: 2, firstName: 'Tom', lastName: 'Dale'}),
App.Person.create({id: 3, firstName: 'Peter', lastName: 'Wagenet'}),
App.Person.create({id: 4, firstName: 'Erik', lastName: 'Bryn'})
]
});
Your template would look like:
{{view Ember.Select
contentBinding="App.peopleController"
selectionBinding="App.selectedPersonController.person"
optionLabelPath="content.fullName"
optionValuePath="content.id"}}
Again, here's a jsFiddle example: http://jsfiddle.net/ebryn/zgLCr/
check out the answers to a similar question: How to bind value form input select to attribute in controller
In the examples a CollectionView is used with an tagName=select. You may find this helpful in getting it work.
EDIT: Since I was looking to implement a select myself, here is the solution I came up with:
views/form.js.hjs:
{{#view contentBinding="App.typeController" valueBinding="type" tagName="select"}}
{{#each content}}
<option {{bindAttr value="title"}}>{{title}}</option>
{{/each}}
{{/view}}
{{#view Ember.Button target="parentView" action="submitEntry"}}Save{{/view}}
The select is part of a form. I do check for the submit event and in there read the value:
app.js.coffee
# provides the select, add value: 'my_id' if you need differentiation
# between display name (title) and value
app.typeController = Ember.ArrayProxy.create
content: [{title:'Energy'}, {title:'Gas'}, {title:'Water'}]
# simplified version, but should prove the point
app.form_view = Ember.View.create
templateName: 'views_form'
type: null
submitEntry: () ->
console.log this.$().find(":selected").val()
Hope this helps.
This isn't an Answer, just a fix on the broken jsfiddle link.. Apparently jsfiddle has no love for ember :/ But JsBin does! http://jsbin.com/kuguf/1/edit

item-specific actions in ember.js collection views

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.
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.
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?
Here is the part of my view template that has the 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) {
// ??? How do I figure out what item
// the user wanted to remove?
}
});
Yehuda's post Michael linked to demonstrates the correct approach, using a child ItemView inside the each. Not sure why that didn't work for you, you've removed that bit of code from your question unfortunately.
Some of the syntax in Yehuda's answer is slightly out of date so I've updated it and changed it to be a bit more like your question. You can check it out here: http://jsfiddle.net/wmarbut/67GQb/130/ (updated link to jsfiddle 1/21/12)
The thrust of it is
Handlebars
{{#each App.peopleController}}
{{#view App.PersonView personBinding="this"}}
<td>{{view.person.fullName}}</td>
<td><button {{action removeItem target="view"}}>Delete</button>
{{/view}}
{{/each}}
Javascript
App.PersonView = Ember.View.extend({
tagName: 'tr',
person: null,
removeItem: function() {
var person = this.get('person');
App.peopleController.removeObject(person);
}
});
Thanks to Tom Whatmore fiddle I found answer to the same question.
After reading trek intro, instead of personBinding="this", I'd rather use {{action removeItem person}} to explicitly indicate object on which action should be performed.
<script type="text/x-handlebars">
<table>
{{#each person in App.peopleController}}
{{#view App.PersonView}}
<td>{{person.fullName}}</td>
<td><button {{action removeItem person}}>Delete</button>
{{/view}}
{{/each}}
</table>
</script>
In the view I'd use var person = evt.context; to get person object.
App = Ember.Application.create();
App.Person = Ember.Object.extend({
fullName: function() {
return this.get('firstName') + ' ' + this.get('lastName');
}.property('firstName', 'lastName')
});
App.peopleController = Ember.ArrayProxy.create({
content: [App.Person.create({ firstName: "Yehuda", lastName: "Katz" }),
App.Person.create({ firstName: "Tom", lastName: "Dale" })]
});
App.PersonView = Ember.View.extend({
tagName: 'tr',
removeItem: function(evt) {
var person = evt.context;
App.peopleController.removeObject(person);
}
});
You can play with this fiddle jsfiddle.net/67GQb/127
Not sure if this the best way but I've put the item index or item name as a property of the tag and then use jQuery to fetch it.
// template
{{#each App.itemsController}}
<tr itemName="{{itemName}}">
<td>{{itemName}}</td>
<td><a href="#" {{action "removeItem" on="click"}}>Delete</a></td>
</tr>
{{/each}}
// Javascript
window.App.ListView = Ember.View.create({
templateName: 'listView',
removeItem: function (event) {
var id = this.$().parent().parent().attr('itemName');
...
}
});
Hope this helps.