javascript - Ember.js help for router map -
i want url: localhost#/234/23/456/524jk53 (/one_id/two_id/three_id/four_id)
stat.router.map(function () { this.resource('one', {path: '/:one_id'}, function(){ this.resource('two', {path: '/:two_id'}, function(){ this.resource('three', {path: '/:three_id'}, function () { this.resource('four', {path: '/:four_id'}); }); }); }); }); and separation of templates:
<script type="text/x-handlebars"> {{outlet one}}<br> {{outlet two}}<br> {{outlet three}}<br> {{outlet}} </script> <script type="text/x-handlebars" data-template-name="one"> one, {{linkto 'two'}}two{{/linkto}} </script> <script type="text/x-handlebars" data-template-name="two"> two, {{linkto 'three'}}three{{/linkto}} </script> <script type="text/x-handlebars" data-template-name="three"> three, {{linkto 'four'}}four{{/linkto}} </script> <script type="text/x-handlebars" data-template-name="four"> 4 </script> route:
app.oneroute = em.route.extend({ rendertemplate: function() { this.render('two', {outlet: 'two'}); this.render('three', {outlet: 'three'}); this.render('four', {outlet: 'four'}); } }); i have error: assertion failed: cannot call 'id' on undefined object.
please, me write router.map application's hierarchy
okay, first up, can remove / { path: '/:dynamic_id' }.
next, need understand when dynamic segment expected within route referencing in linkto helper, need pass model (or other) objects additional parameters linkto helper context each dynamic segment.
this why you're getting error. router should this:
stat.router.map(function () { this.resource('one', {path: ':one_id'}, function(){ this.resource('two', {path: ':two_id'}, function(){ this.resource('three', {path: ':three_id'}, function () { this.resource('four', {path: ':four_id'}); }); }); }); }); and in template, should passing context segments, instance:
{{linkto 'two' modelone modeltwo}}hello world!{{/linkto}} anyway, think need refine question what. trying achieve? if dynamic segments aren't model ids, might need @ overriding serialize callback in relevant route files.
Comments
Post a Comment