我有一个node.js(服务器)和backbone.js(客户端)应用程序 - 我可以加载和启动我的骨干网页应用程序...并初始化路由器,但我的默认路由( “。*”)没有被调用。我可以在初始化路由器后手动调用索引函数,但当我通过rails构建骨干应用程序时,我不必采取这一步骤。未处理的路线
有没有人有线索为什么发生这种情况?
添加代码(在CoffeeScript的):
class NodeNetBackbone.Routers.RegistryPatients extends Backbone.Router
routes:
'' : 'index'
'.*' : 'index'
'/index' : 'index'
'/:id' : 'show'
'/new' : 'new'
'/:id/edit' : 'edit'
initialize: ->
console.log 'init the router'
@registry_patients = new NodeNetBackbone.Collections.RegistryPatients()
# TODO: Figure out why this isn't sticking...
@registry_patients.model = NodeNetBackbone.Models.RegistryPatient
# TODO: Try to only round trip once on initial load
# @registry_patients.reset($('#container_data').attr('data'))
@registry_patients.fetch()
# TODO: SSI - why are the routes not getting processed?
this.index()
index: ->
console.log 'made it to the route index'
view = new NodeNetBackbone.Views.RegistryPatients.Index(collection: @registry_patients)
# $('#container').html('<h1>Patients V3: (Backbone):</h1>')
$('#container').html(view.render().el)
你能告诉你如何定义你的路由一些例子吗? – loganfsmyth 2012-02-15 22:26:10
没有代码的例子,我们看不到有什么可以修复的,所以请提供你的代码 – Sander 2012-02-16 10:04:18
嗯,我只是想预测一下,但是,默认路由不是'*。''。它只是''''(空字符串)。 – 2012-02-16 13:40:50