2

テンプレートの定義

<script type="text/x-handlebars" id="application">
    {{outlet}}
</script>

<script type="text/x-handlebars" id="markets/sources">
    {{#each model }}
        <span>{{source_channel}}</span>
        <span>{{handle}}</span>
    {{/each}}

</script>

<script type="text/x-handlebars" id="markets">
    <div class="leftside">
    {{#each model }}
        <span>{{name}}</span>
        <span>{{created}}</span>
        {{#linkTo 'markets.sources' this class="link" }}<span>go to</span>{{/linkTo}}  
    {{/each}}
    </div>
    <div class="rightside">
        {{outlet}}
    </div>
</script> 

ルートを定義

var App = Ember.Application.create();

App.Router.map(function() {
    this.route("index", {path: "/"});                                                       
    this.resource('markets', {path: "/markets"}, function() {
        this.route("sources", { path: "/:markets_id" });
    });
});

App.IndexRoute = Ember.Route.extend({
    redirect: function() {
        this.transitionTo('markets');
    }
});

App.MarketsRoute = Ember.Route.extend({
    model: function () {
        return App.Markets.find();
    }
});

App.MarketsSourcesRoute = Ember.Route.extend({
    model: function(){
        return App.Sources.find();
    },
    serialize: function(model) {
        return { markets_id: model.id };
    }
});

モデルの定義

App.Store = DS.Store.extend({
   revision: 12,
   adapter: DS.FixtureAdapter
});

App.Markets = DS.Model.extend({
    name: DS.attr("string"),
    created: DS.attr("string")
});

App.Sources = DS.Model.extend({
   source_channel: DS.attr("string"),
   handle: DS.attr("handle")
});

App.Sources.FIXTURES = [
    {id:1, markets_id:"1310", source_channel:"sc1", handle: "hn1"},
    {id:2, markets_id:"1310", source_channel:"sc2", handle: "hn2"},
    {id:3, markets_id:"1310", source_channel:"sc3", handle: "hn3"},
    {id:4, markets_id:"1512", source_channel:"sc4", handle: "hn4"},
    {id:5, markets_id:"1512", source_channel:"sc5", handle: "hn5"}
];

App.Markets.FIXTURES = [
    {id:"1310", name:"test1", created:"2012-2-3"  },
    {id:"1320", name:"test2", created:"2012-2-13"  },
    {id:"1512", name:"test3", created:"2012-2-23"  }
]; 

コントローラーの定義

App.MarketsController = Ember.ObjectController.extend({}); 
App.MarketsSourcesController = Ember.ObjectController.extend({});

EmberJs を使用して {{#linkTo}} をクリックすると、サブ コンテンツが表示されます

ここでは、私が望む結果を見ることができません._そして、左側のアンカータグをクリックすると右側に黒いコンテンツが表示され
ます.「ソース」モデルは「市場/ソース」テンプレートと統合されていないと思います.
左側のアンカー タグをクリックすると、ソース モデルの正しい結果が表示されます。

できればjsbinやjsfiddleで結果を見たい

4

1 に答える 1