Closed paulmillr closed 11 years ago
we can add global event anyway. and people who want to use it in views would be free to do so
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.
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.
let’s move to gh-314
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?