How do I click to edit on a collection and update that specific element?


I was following the tutorial but the tutorial is for the object controller. In an Array controller how do I properly pass in the object for the text field so it triggers the update for that model object?

Right now I can double click, and then type in some value, and if I hit enter I get the value plus undefined method set.

Uncaught TypeError: Object asdasdasdasdasd has no method 'set'

I guess it’s passing the raw value into the controller and then trying to run methods off of that. How do I get it to pass the actual model?


    <li {{bind-attr class="isEditing:editing"}} {{action "editWorkout" this on="doubleClick"}}>
      {{#if isEditing}}
        {{view Ember.TextField class='edit' action="updateWorkout"}}
        {{#link-to 'workout' this}} {{title}} {{/link-to}}


EmberWorkouts.WorkoutsController = Ember.ArrayController.extend

    editWorkout: (workout) ->
      workout.set('isEditing', true)

    createWorkout: ->
      title = @get('newWorkoutName')

      workout = @store.createRecord('workout', title: title)
      @set('newWorkoutName', '')

    updateWorkout: (workout) ->
      workout.set('isEditing', false)

  isEditing: false

Repo here if you want to investigate:


First I’m not sure how this works because ‘isEditing’ is a controller property and in ArrayController you should write {{controller.isEditing}} as opposed to the ObjectController which acts like a proxy for the model.

Second thing: I don’t know if in purpose you would like to lazily perform the updates, but if you want to use standard bindings you can achieve that by binding the value of each TextField view to the iterated item’s property, here’s an example:

Visit Bootstrap for Ember: