无法使Marionette路由工作

时间:2015-01-29 17:00:03

标签: ruby-on-rails marionette

我无法让Marionette路由工作

@Arc = do(Backbone, Marionette) ->
  App = new Marionette.Application

  API =
    listContacts: ()->
      console.log "from listContacts"

  class MyRouter extends Marionette.AppRouter
    appRoutes:
      "notes" : "listContacts"
    controller: API

  App.router = new MyRouter()


  App.on 'start', ->
    console.log "in on start"
    if Backbone.history
      Backbone.history.start(pushStart: true)

  App

console.log "before"
@Arc.start()
console.log "after"

访问localhost:3000/notes不会记录消息from listContacts。如果我转pushState: false访问localhost:3000/#notes确实有效。

1 个答案:

答案 0 :(得分:1)

应该是Backbone.history.start(pushState: true),而不是pushStart