templates - I cannot see the sub content when I click {{#linkTo}} in emberJs -


i' see sub content when click {{#linkto}} using emberjs
template file

<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' class="link" }}<span>go to</span>{{/linkto}}       {{/each}}     </div>     <div class="rightside">         {{outlet}}     </div> </script>  

this file define route.

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 };     } }); 

this model file

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"  } ];  

this controller part

app.marketscontroller = ember.objectcontroller.extend({});  app.marketssourcescontroller = ember.objectcontroller.extend({}); 

in here, can not see result want._ , display black content in right side when click anchor tag in left side
think, "sources" model not integrated "markets/soruces" template.
i'd see correct result sources model when click anchor tag in leftside.

if possible, i'd see result on jsbin or jsfiddle

the reason app.markets doesn't contain properties source_channel , handle.

you might have expected model hook of app.marketssourcesroute called correct model. model wouldn't have been called , pass via linkto helper model, in case single row in app.markets. said in ember guides

a route dynamic segment have model hook called when entered via url. if route entered through transition (e.g. when using linkto handlebars helper), model context provided , hook not executed. routes without dynamic segments execute model hook.

so it'll better call app.sources.find() in setupcontroller called always.

i've updated jsbin. revert if have queries.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -