1

ここで奇妙な問題が発生しました。「ParentView」で、レンダリングされた Ember.CollectionView 内のアクションをキャッチしたいと考えています。

{{#collection contentBinding="view.content"}}
    <a href="#" {{action insideCollection target="parentView">{{view.content}}</a>
{{/collection}}

ただし、CollectionView 内の parentView は依然として View のサブクラスであり、ParentView 自体ではありません (私の例では ApplicationView)。では、ApplicationView 内で Handlebars-Action をキャッチするにはどうすればよいですか?

これは、自分で問題を確認するためのフィドルです: http://jsfiddle.net/smgMt/3/

何か案は?

4

1 に答える 1

4

When using the collection helper, there is an implicit view created for each content in the block. So here, if you want to access the ApplicationView, you have to call twice parentView.

The second hint is you must prefix this chain by the keyword view to access the current view properties.

<script type="text/x-handlebars" data-template-name="application">
  <h1>Hello from Ember.js</h1>
  <button {{action test target="view"}}>Click to Test</button>
  {{#collection contentBinding="view.content" tagName="ul"}}
    <a href="#" {{action insideAction target="parentView.parentView"}}>{{view.content}}</a>
 {{/collection}}
</script>​

http://jsfiddle.net/smgMt/14/

于 2012-11-14T13:34:21.507 に答える