Property Scopes in an ArrayController?


#1

Hi all, this is probably a grossly simple question to answer, so I apologize if I am cluttering this forum in advance. But can’t seem to get any answers on stack overflow so reposting it here.

I am displaying a list of items that share the same model and controller. I made these items editable via a <button {{ action 'edit' }}> next to each item which toggles a boolean value of a property “isEditable” in the controller. However clicking this button causes all items in the list to become editable because they all share the controller property “isEditable”. The desired effect is to make a single item editable at a time instead of all items at once.

A simplified version of my template looks like this:

{{#if isEditing}}
      <p>{{input type="text" value=title}}</p>
      <button {{action 'doneEditing'}}>Done</button>
{{else}}
      <span class="title">{{title}}</span>
      <button  {{action 'edit'}}><span class="edit"</span></button>
{{/if}}

and the controller looks like this

App.ItemController = Ember.ArrayController.extend({
isEditing : false,
actions : {
	edit : function(){
		this.set('isEditing', true);
	},
	doneEditing : function(){
		this.set('isEditing', false);
	},
}

});

Anybody know how to accomplish this? Is it because each item shares the “isEditable” property? If so, how do I get around this? I don’t want to put this into the model because it’s purely a display thing, even though I know I can get it to work doing that.


#2

answered here, thanks!:

[http://stackoverflow.com/questions/18938215/emberjs-property-scopes-in-an-arraycontroller][1]