chaplinjs / chaplin

HTML5 application architecture using Backbone.js
http://chaplinjs.org
Other
2.85k stars 232 forks source link

Controller titles are insufficient #309

Closed paulmillr closed 11 years ago

paulmillr commented 11 years ago

Consider basic application like ost.io (routes.coffee).

User goes to :login/:repoName/topics/:topicNumber, topics#show matches.

Controller initializes model and view and fetches model from the server. It would be good to show topic name in page title. But topic name will be only available after model fetch so controller’s title will be useless here. And we don’t have any global event to change document title. This is pretty usual situation, e.g. user pages in all apps with auth.

So, maybe we should add it or is there some better solution?

andriijas commented 11 years ago

we can add global event anyway. and people who want to use it in views would be free to do so

molily commented 11 years ago

Yep, we had this problem on moviepilot.com, too. AFAIR we used a global event and the SyncMachine to set the title (don’t know how it’s done at the moment). Example (event name debatable, of course):

@model.synced -> mediator.publish '!adjustTitle', @model.get('title')

Doing that manually is the easiest and most reliable way I think. Chaplin can’t make assumptions about whether a model will be fetched or initialized with data.

andriijas commented 11 years ago

What we could do Is to add !adjustTitle event listener to dispatcher.coffee and adjust the current @adjustTitle to take a subtitle string instead of context.

An additional method would be needed for keeping support with controller and startupController.

paulmillr commented 11 years ago

let’s move to gh-314