Created
February 17, 2012 10:26
-
-
Save nvh/1852497 to your computer and use it in GitHub Desktop.
Spine Substack
This file contains hidden or 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: | |
resources: App.Resources | |
users: App.Users | |
routes: | |
'/resources' : 'resources' | |
'/users' : 'users' | |
default: 'users' | |
className: 'stack root' |
This file contains hidden or 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.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' |
This file contains hidden or 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 Spine.SubStack extends Spine.Stack | |
constructor: -> | |
for key,value of @routes | |
do (key,value) => | |
@routes[key] = => | |
@active() | |
@[value].active(arguments...) | |
super |
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
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