balanced/balanced-dashboard — pull request #428 by victorlin (2013-07-25 07:51:25+00:00)
Title: Improve title updating mentioned in issue #135

I have already implemented the title design proposed by @dmdj03. In order to avoid conflicting to other use of title attribute in Route object, I changed the name to `page_title` instead.

Also, route instance and a `set_title` function will be passed to the page_title function. In this way, when the data is loading from server, you can call `set_title` later to update the page title.

To make it easy to support a deferred title update, you can use a helper function `Balanced.Utils.loadSetTitle` like this:

```
Balanced.CardRoute = Balanced.AuthRoute.extend({
page_title: function (route, set_title) {
var card = route.controller.content;
return Balanced.Utils.loadSetTitle(card, set_title, function () {
return 'Card: loading ...';
}, function () {
return 'Card: {0} ({1} {2})'.format(
card.get('name'),
card.get('last_four'),
Balanced.Utils.toTitleCase(card.get('brand'))
);
});
}
});
```

The first argument is the model instance, the third argument is the function for returning loading title, the last argument is called when the data is loaded and return the title.

I think title updating of almost all pages are supported properly, except logs and invoices. It appears they are iframe style loading rather than Ajax style loading. I didn't look them in details yet.