nusmodifications / nusmods

🏫 Official course planning platform for National University of Singapore.
https://nusmods.com
MIT License
586 stars 319 forks source link

Change window title on different pages #66

Closed yangshun closed 7 years ago

ashrayjain commented 10 years ago

Hey, could you elaborate on how the title should change for different pages? Thanks!

yangshun commented 10 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?

thebengeu commented 10 years ago

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?

yangshun commented 7 years ago

Done in v3