最近EmberRouterで気付いたのは、リーフルート(子ルートのないルート)へのナビゲートのみが許可されていることです。
今、私が間違ったことをしていない限り、これは設計上のバグ/間違いのようです。
たとえば、次のようなものを考えてみましょう。
私にはプロジェクトのコレクションがあり、各プロジェクトには多くの共同作業者がいます。これにより、3列のレイアウト(標準のデスクトップメールクライアントのようなもの)でUIを構築したいと思います。左側には、プロジェクトのリストがあります。プロジェクトの中央の列には共同編集者のリストが表示され、共同編集者をクリックするとその詳細が右側の列に読み込まれます。
/projects/1
ここで、プロジェクトをクリックしたときに移動/projects/1/collaborators/23
し、共同作業者をクリックしたときに移動したいルーティングを使用します。
ネストされたルートの最初の部分を示すルーターは次のとおりです。
App.reopen(
Router: Ember.Router.extend(
enableLogging: true
location: 'hash'
root: Ember.Route.extend(
index: Ember.Route.extend(
route: '/'
redirectsTo: 'projects'
)
projects: Ember.Route.extend(
# This route is not routable because it is not a leaf route.
route: '/projects'
connectOutlets: (router) ->
# List projects in left column
router.get('applicationController').connectOutlet('projects', App.projects)
show: Ember.Route.extend(
# This route is routable because it is a leaf route.
route: '/:project_id'
connectOutlets: (router, project) ->
# Render the project into the second column, which actually renders
# a list of collaborators.
router.get('projectsController').connectOutlet('project', project)
)
)
)
)
)
root.projects.show
ご覧のとおり、この行のために、Emberはに移行するまでupdateRouteを呼び出しません(URLを設定します)https://github.com/emberjs/ember.js/blob/master/packages/ember-routing/lib/routable .js#L81
他の誰かがこのようなことをしましたか?これを設計するためのより良い方法はありますか?