1

以下で私がやろうとしているのは、パーシャルを使用してビューをよりモジュール化することです。残念ながら、これは機能しません。

私は得る


Uncaught TypeError: Cannot read property 'view' of undefined in the (compiled) _dataForLeftPane.js @ the following line,
  stack1 = foundHelper ? foundHelper.call(depth0, stack1, {hash:{}}) : helperMissing.call(depth0, "outlet", stack1, {hash:{}});

container.hjs で宣言されたパーシャルを削除して (以下のコードを参照)、代わりにそれぞれのコンテンツを配置すると、すべてが機能します。しかし、パーシャルを導入したときにのみ、機能が停止します。

file: app_router.js.coffee

root: Ember.Route.extend(
  index: Ember.Route.extend(
    route: '/'
    connectOutlets: (router) ->
      router.get('applicationController').connectOutlet('container')
      router.get('containerController').connectOutlet('dataForLeftPane', 'dataForLeftPane', [{login:'wycats'},{login:'tomdale'}])
      router.get('containerController').connectOutlet('dataForRightPane', 'dataForRightPane', [{id:'1234'},{id:'qwerty'}])
  )
)
file: views/application_view.js.coffee

App.ApplicationView = Ember.View.extend(
  templateName: 'application'
)

App.ContainerView = Ember.View.extend(
  templateName: 'a/container'
)

App.DataForLeftPaneView = Ember.View.extend(
  templateName: 'a/dataForLeftPane'
)

App.DataForRightPaneView = Ember.View.extend(
  templateName: 'a/dataForRightPane'
)
file: templates/a/container.hjs

{{> _a_leftPane}}
{{> _a_rightPane}}
file: templates/a/_leftPane.hbs

{{outlet dataForLeftPane}}
file: templates/a/_rightPane.hbs

{{outlet dataForRightPane}}
file: templates/a/dataForRightPane.hjs

{{#each person in controller}}
  {{person.id}}
{{/each}}
file: templates/a/dataForLeftPane.hjs

{{#each person in controller}}
  {{person.name}}
{{/each}}
4

1 に答える 1

0

別のテンプレート内のビュー ヘルパーを使用してビューを「呼び出す」ことができます。

file: templates/parentView.hjs
{{view.someProperty}}
//here is the parent view calling a template
{{view "App.templateView" contentBinding="view.content"}}

これにより、指定された App.templateView が、レンダリングされたビューの渡されたコンテンツ プロパティへのコンテンツ バインディングと共に挿入されます。必要なコンテンツを templateViews コンテンツとして渡すことができます。

これはおそらくあなたがやりたいことですが、あなたの質問を正しく読んだかどうかわかりません.

また、これは、渡されたローカルを使用して Rails でパーシャルをレンダリングすることに意味的に近いです。「部分的」について言及していたので、それがあなたが探している解決策かもしれないと思います。

于 2012-12-26T16:51:04.317 に答える