1
votes
  • I have a personArrayController with an addField and deleteField methods
  • I have a PersonCollectionView class (inherited from CollectionView)
  • HandleBars is making the connection:
    {{view PersonCollectionView contentBinding="personArrayController"}}
  • I need to have a button in each view of the collectionView to allow deleting the selected element.

The child View template needs to call the deleteField from the personArrayController. target is used because otherwise the router will be triggered.

Display of the views is done correctly but when I click on a "delete" button the target is not found (the personArrayController is not triggered).

How can I access the personArrayController from my template view ?
I was thinking this controller was accessible with the target="view.content"...but it seems logical the "view.content" is the current array element and not the arrayController...

App.PersonCollectionView=Ember.CollectionView.extends({
itemViewClass: Ember.View.extend({
    template: Ember.Handlebars.compile(<button {{action deleteField view.content target="view.content"}});
  })
})
1

1 Answers

1
votes

You can specify "controller" as target:

App.PersonCollectionView=Ember.CollectionView.extends({
itemViewClass: Ember.View.extend({
    template: Ember.Handlebars.compile(<button {{action deleteField view.content target="controller"}});
  })
})