【发布时间】:2012-09-03 14:18:42
【问题描述】:
我想在视图上启动一个主干应用程序,它已经由 Rails 渲染。
这是我的路由器代码
class App.Routers.Dashboard extends Backbone.Router
routes:
'': 'index'
'locations/:id': 'showLocation'
index: ->
alert "Dashboard page"
initialize: ->
@route(/\/?/, 'index', @index);
然后在渲染视图中,我启动应用程序
$ ->
App.appRouter = new App.Routers.Dashboard()
Backbone.history.start
pushState: true
root: "/dashboard"
但是,如果我打开页面
http://localhost:3000/dashboard
路由器没有进入“索引”状态。
我错过了什么吗?
【问题讨论】:
标签: ruby-on-rails-3.2 backbone-routing