Note that there are some explanatory texts on larger screens.

plurals
  1. POwhy doesn't the ember route update the url correctly when using dynamic segments?
    text
    copied!<p>this is a basic ember routing example that doesn't update the url to /posts correct when there is a child route in posts with dynamic segments. all the other routes (including the dynamic segments) correctly update the url. if i take out the dynamic segment child route (called 'show', under 'posts') then it updates the url correctly. here's the fiddle code : <a href="http://jsfiddle.net/inconduit/NbPpM/3/" rel="nofollow">http://jsfiddle.net/inconduit/NbPpM/3/</a></p> <p>and to view fiddle in action where it updates the urls, look here: <a href="http://fiddle.jshell.net/inconduit/NbPpM/3/show/#" rel="nofollow">http://fiddle.jshell.net/inconduit/NbPpM/3/show/#</a></p> <p>to summarize - when you click 'Posts' the url should update to show /posts , but it does not.</p> <p>here's the javascript:</p> <pre><code>App = Ember.Application.create({ ready: function() { App.initialize(App.Router.create({ enableLogging: true })); } }); App.Post = Ember.Object.extend({ title: null, body: null }); App.posts = []; App.posts.pushObject(App.Post.create({id:'0', title: "Test post 1", body: "How awesome is Ember.js"})); App.posts.pushObject(App.Post.create({id:'1', title: "Test post 2", body: "I love working on awesome projects"})); App.posts.pushObject(App.Post.create({id:'2', title: "Test post 3", body: "I like cats"})); App.ApplicationController = Ember.ObjectController.extend(); App.ApplicationView = Ember.View.extend({ templateName: "application_view" }); App.PostsController = Ember.ArrayController.extend(); App.PostsView = Ember.View.extend({ templateName: 'posts_view' }); App.PostController = Ember.ObjectController.extend(); App.PostView = Ember.View.extend({ templateName: 'post_view' }); App.AboutController = Ember.ObjectController.extend(); App.AboutView = Ember.View.extend({ templateName: 'about_view' }); App.Router = Ember.Router.extend({ root: Ember.Route.extend({ goToPostsIndex: Ember.Route.transitionTo('posts.index'), goToAbout: Ember.Route.transitionTo('about'), goToShowPost: Ember.Route.transitionTo('posts.index.show'), index: Ember.Route.extend({ route: '/', redirectsTo: "posts.index" }), posts: Ember.Route.extend({ route: '/posts', connectOutlets: function (router) { router.get('applicationController').connectOutlet('posts', App.posts); }, index: Ember.Route.extend({ route: '/', connectOutlets: function (router) { router.get('applicationController').connectOutlet('posts', App.posts); }, show: Ember.Route.extend({ route: '/:post_id', connectOutlets: function (router, post) { router.get('postsController').connectOutlet('post', post); }, deserialize: function(router, params) { var id = params.post_id, i = 0; for (i = 0; i &lt; App.posts.length; i += 1) { if (App.posts[i].id === id) { return App.posts[i]; } } }, serialize: function(router, context) { var rtnVal = {}, id = context.get('id'); if (context) { rtnVal = {post_id: id}; } return rtnVal; } }) }), }), about: Ember.Route.extend({ route: '/about', connectOutlets: function (router) { router.get('applicationController').connectOutlet('about'); } }) }) }); </code></pre> <p>​`</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload