Skip to content

Instantly share code, notes, and snippets.

@fholgado
Created June 18, 2012 18:32
Show Gist options
  • Save fholgado/2949879 to your computer and use it in GitHub Desktop.
Save fholgado/2949879 to your computer and use it in GitHub Desktop.
Fix routing for substacks
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)
@nvh
Copy link

nvh commented Jun 18, 2012

I can't reproduce your problem with my code.
Are you calling Spine.Route.setup() before navigating? (see the docs )

@fholgado
Copy link
Author

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 ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment