Toggle isediting


#1

Hi there,

i am new to ember. I am still experimenting on it.

I have very simple issue which i cant solve by using ember.

Basicly the trouble is i have a list of title when i click on one them it converts the text into input so that user can edit.

However since its a list of title i want to disable the other items isediting property to false…

Anyway less talk show me the code part

   {{#each query in model itemController='query'}}
<tr>
    {{#if query.isEditing}}
    <td>{{input value=query.query}}</td>
    {{else}}
    <td {{action 'editTitle' this}}>{{query.query}}</td>
    {{/if}}
</tr>
{{/each}}

 App.QueriesController = Ember.ArrayController.extend({
    itemController: 'query',
});
App.QueryController = Ember.ObjectController.extend({
    isEditing: false,
    actions: {
        editTitle: function (item) {
            this.set('isEditing', true);
        }
    }
});

#2

You could set needs: ['queries'] on the QueryController so each item controller has access to the array controller. Then before an item is set to editable, have an event on the array that causes editing to end on each item.

Given that this arrangement of controllers is disappearing in Ember 2.0, it’s worth considering using components for this instead.