How to make parent stack active when nested stack responds to route

259 Views Asked by At

Question

I'm developing a fairly large app and I've run into a problem that seems common. But I haven't been able to find any solutions to it on the spine groups or here at SO.

So the question is, how do I make sure, that parent stacks becomes active when nested stacks responds to a route. How is this solved properly?

1

There are 1 best solutions below

1
On

I managed to solve this by simply using @active within the parent controller for the route. This is doing the same as this.active. Here is an example of how i've done it…

Spine   = require('spine')
$       = Spine.$

# Controllers
Main      = require('controllers/posts/posts.main')
Nav       = require('controllers/navigation/navigation')

class Posts extends Spine.Controller
  className: 'posts top-controller'

  constructor: ->
    super
    @nav      = new Nav
    @main     = new Main

    @routes
      '/posts/new': ->
        @active()
        @nav.post.active()
        @main.new.active()

      '/posts/suggestion': ->
        @active()
        @nav.normal.active(title: "Groups near by")
        @main.matches.active()

      '/posts/:id': (params) ->
        @active()
        @nav.chat.active()
        @main.show.active(params)

    @append @nav, @main

module.exports = Posts