2

Ember.js で複数の名前付きアウトレットを使用しようとしています。以下の私のアプローチは正しいですか?

マークアップ:

<script type="text/x-handlebars" data-template-name="application">
    <div id="mainArea">
        {{outlet main_area}}
    </div>
</script>

<script type="text/x-handlebars" data-template-name="home">
    <ul id="sections">
        {{outlet sections}}
    </ul>
    <ul id="categories">
        {{outlet categories}}
    </ul>
</script>

<script type="text/x-handlebars" data-template-name="sections">
    {{#each section in controller}}
        <li><img {{bindAttr src="section.image"}}></li>
    {{/each}}
</script>

<script type="text/x-handlebars" data-template-name="categories">
    {{#each category in controller}}
        <img {{bindAttr src="category.image"}}>
    {{/each}}
</script>​

JS コード:

ここでは、さまざまなコントローラーのコンテンツをサーバーから取得したデータに設定し、アウトレットを対応するビューに接続します。HomeController にはコンテンツがないため、そのコンテンツを空のオブジェクトに設定します。これは、このエラー メッセージを取り除くためのハックです。

キャッチされないエラー: アサーションに失敗しました: set('categories' ) をオブジェクト プロキシの 'content' プロパティに委譲できません: その 'content' は定義されていません。

App.Router = Ember.Router.extend({
    enableLogging: false,
    root: Ember.Route.extend({
    index: Ember.Route.extend({
        route: '/',

        connectOutlets: function(router){
            router.get('sectionsController').set('content',App.Section.find());
            router.get('categoriesController').set('content',  App.Category.find());
            router.get('applicationController').connectOutlet('main_area', 'home');
            router.get('homeController').connectOutlet('home', {});
            router.get('homeController').connectOutlet('categories', 'categories');
            router.get('homeController').connectOutlet('sections', 'sections');
            }
        })
    })
});

</p>

4

1 に答える 1

5

助けがあれば、Ember.Controller ではなく Ember.ObjectController に接続していたため、このエラーが発生しました。

于 2013-01-08T15:07:46.387 に答える