Created
June 18, 2012 18:32
-
-
Save fholgado/2949879 to your computer and use it in GitHub Desktop.
Fix routing for substacks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class App.Root extends Spine.Stack | |
controllers: | |
feeds: App.Feeds | |
routes: | |
'/feeds' : 'feeds' | |
className: 'stack root' | |
constructor: -> | |
super | |
destination = window.location.hash[1..] | |
if destination.length <= 1 | |
# This should be your default route | |
destination = '/feeds' | |
activate_hash = { | |
history: false | |
match: [destination] | |
shim: false | |
trigger: true | |
} | |
# Hack to reset navigation by going to another route | |
# and then navigating where we need to go! | |
Spine.Route.navigate('/', true) | |
Spine.Route.navigate(destination, true) | |
@activate(activate_hash) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You know, I never thought about this. I AM calling
Spine.Route.setup()
, but I was doing it before I initialized the root controller. I just moved it so that this is called after initializing the root controller and everything works magically (without this ugly hack).FUUUUUUUUUUUUUU.
Thanks for making me realize this ;)