Updating page title with Backbone so it shows properly in browser history

Discussion in 'JavaScript Forum' started by darkix, Apr 10, 2013.

  1. darkix

    darkix New Member

    I'm working on an built out with backbone and backbone-layout-manager. When I need to do a view change, I need to update the page to a new title. I've tried adding a convenience method called setTitle,\[code\]setTitle: (new_title) -> document.title = new_title console.log "changed title to: #{new_title}"\[/code\]that I can call in my router, on a route change. This works great, however, there's a problem. When I check my browser history, it's evident that it shows the title that was associated with the previous page. Example (1-3 in order of pages visited):\[code\]1. localhost/#/home/ - "Website"2. localhost/#/blog/ - "Website - Home"3. localhost/#/home/ - "Website - Blog"\[/code\]I see that the router is not calling the route until after the url has changed and my browser, Chrome, has added the page to its history.My question is, how can I update the title of the page so that the title is actively reflected in my browser history.
     

Share This Page