Closed yangshun closed 7 years ago
I do not know of a good elegant way to do this. In a previous single-page app I worked on, we set the titles in the controllers. For NUSMods, I think we can have a titles module containing all the routes : title mapping that is called by the Backbone.Router on a navigate event and page load.
Some ideas:
@ahbeng any suggestions?
TIL that pushState
has a title
parameter that no browser has implemented: http://lists.whatwg.org/htdig.cgi/whatwg-whatwg.org/2010-June/026827.html. There doesn't seem to be an idiomatic way to do it in Backbone/Marionette.
Could probably extend Marionette's AppRouter
similar to what Backbonejs-Router-Title-Helper
is doing. The key exception to that declarative approach where it might also be good to set the title is along with the navigate
calls when the timetable is changed - having titles like "Timetable (MA1101R, CS1231, ...) - NUSMods" might make it easier to find a state to go back to. But that probably only appeals to a very small set of power users?
Done in v3
Hey, could you elaborate on how the title should change for different pages? Thanks!