Setting page title with ember.js

ember.js

Solution

I took this approach:

Ember.Route.reopen({
    enter: function(router) { 
        this._super(router)

        # Set page title
        name = this.parentState.get('name')
        if (!Em.none(name)) {
            capitalizedName = name.charAt(0).toUpperCase() + name.slice(1)
            $(document).attr('title', "Website - " + capitalizedName)
        }
   }
})

A few issues came up with using navigateTo, this ended up being more reliable and cleaner for my situation at least.

Problem

What is the best way to set the page's title, so that when transitioning between urls, the title will reflect the new state? Is there a way to set the Router to do this? I want a method that allows me to set a page title schema for each state. So, if the route has parameters, they will be passed into the pageTitle: ``` sessions : Ember.Route.extend({ route:"/sessions", connectOutlets : function(router) { //... }, pageTitle:function(){ return "Sessions"; }, }) ``` I'm open to any suggestions as to how it is best to implement this type of functionality on the Model or someplace else.

Original source

Related problems