I'm pretty new to spine and right now I'm trying to setup my first small app.
I've got a Posts Controller where defining 2 routes: One showing a specific post and one showing all posts
class Posts extends Spine.Controller
className: 'posts'
constructor: ->
super
@main = new Main
@routes
'/post/:id': (params) ->
@main.show.active(params)
'/posts': ->
@main.show_all.active()
@append @main
Working so far ... Then I've got a posts.main controller where i define my show and show_all controllers
Post = require('models/post')
class Show extends Spine.Controller
className: 'show'
constructor: ->
super
@active @load
load: (params) =>
@item = Post.find(params.id)
@html require('views/post')(@item)
class Show_all extends Spine.Controller
className: 'show_all'
events:
"click .items" : "click"
constructor: ->
super
@active @load
load: =>
@item = Post.all()
@html require('views/posts')(@item)
change: (postId) =>
@navigate("/post", postId)
click: (event) ->
@change(event.target.id)
class Main extends Spine.Stack
className: 'main Stack'
controllers:
show: Show
show_all : Show_all
module.exports = Main
Also working so far When I got to: http://localhost:9294/# I see a list of my posts. Now my target is: When clicking on a post I want to go to /#/post/[ID] This is also working BUT Instead of just seeing the information of the selected post I always get a list of all available posts under the post details. When I hit F5 the list of all posts is gone...
Why is this happening? What must I do to JUST see the post related information?