我有一個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