Skip to content

Instantly share code, notes, and snippets.

@nvh
Created February 17, 2012 10:26
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save nvh/1852497 to your computer and use it in GitHub Desktop.
Save nvh/1852497 to your computer and use it in GitHub Desktop.
Spine Substack
class App.Root extends Spine.Stack
controllers:
resources: App.Resources
users: App.Users
routes:
'/resources' : 'resources'
'/users' : 'users'
default: 'users'
className: 'stack root'
class App.Users extends Spine.SubStack
controllers:
search : Search
show : Show
profile : Profile
routes:
'/users/search' : 'search'
'/users/search?q=:query' : 'search'
'/users/profile' : 'profile'
'/users/:id' : 'show'
default: 'search'
className: 'stack users'
class Spine.SubStack extends Spine.Stack
constructor: ->
for key,value of @routes
do (key,value) =>
@routes[key] = =>
@active()
@[value].active(arguments...)
super
@MikeSilvis
Copy link

what arguments go into here? @[value].active(arguments...)

And when do you ever call new SubStack to actually add the rendering to it.

My Gist: https://gist.github.com/2839845

@nvh
Copy link
Author

nvh commented May 31, 2012

If you pass a function, it will be bound the the activate trigger, so it will be called when the controller is activated, if you don't pass it anything, it will activate the controller.

You subclass the substack controller, and initialize it the same way you would with a stack.

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