javascript - how to define nested routes + ember not rendering template for nested route -
javascript - how to define nested routes + ember not rendering template for nested route -
i have rails 4 + emberjs application. trying create nested routes in ember. refering 'nested routes' section http://emberjs.com/guides/routing/defining-your-routes/. defiend routes post work fine routes 'comments' dont work. current ember routes as:
app.router.map -> @resource 'posts', -> @route 'edit', path: '/:id/edit' @route 'show', path: '/:id' @resource "comments", path: '/:post_id/comments' , -> @route "new"
i have commentsnewroute file as:
app.commentsnewroute = ember.route.extend model: (params) -> post: @store.find 'post', params.post_id
and have template comments.handlebars containing {{outlet}} , comments/new.handlebars containing 'hello world'. have places comments.handlebars , new.handlebars within posts templates @ same level. still, none rendered.
the link-to helper as:
{{#link-to 'comments.new' id classnames='pull-right' }}add new comment{{/link-to}}
the problems 1) params in commentsnewroute empty object , doesnt contain post_id. 2) new comments template isnt rendered when click link points '/#/posts/2/comments/new'. 3) how can display post's objects info on new comments page? doing wrong?
dynamic segment values available route dynamic segment belongs to.
which means should load post on app.commentsroute
, reuse on app.commentsnewroute
, see example
app.commentsroute = ember.route.extend({ model: function (params) { homecoming this.store.find('post', params.post_id); } }); app.commentsnewroute = ember.route.extend({ model: function () { homecoming this.modelfor('comments'); } });
more info
javascript ember.js routes ruby-on-rails-4.1
Comments
Post a Comment