私はnode.js(サーバー)とbackbone.js(クライアント)アプリケーションを持っています - ページに私のバックボーンアプリケーションをロードして初期化することができます...そしてルータを初期化します。 "。*")は呼び出されません。私は手動でルータを初期化した後にインデックス関数を呼び出すことができますが、私はレール上でバックボーンアプリケーションを構築したときにそのステップを実行する必要はありません。ルートは処理されません
これはなぜ起こっているのか誰かが知りませんか? (のCoffeeScriptで)コードを追加
:(手動route
を使用して正規表現のルートを追加しない限り)
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
コード例がなくても何が修正できないのかわかりませんので、コードを入力してください – Sander
まあ、私はちょっと慌てるつもりですが、デフォルトルートは ''*' 'ではありません。それは '' ''(空の文字列)だけです。 –